This repository has been archived by the owner on Mar 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·90 lines (74 loc) · 2.3 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# /bin/install.sh for atomic rsyslog image
prefix=${HOST:-/host}
function install_dir ()
{
source="$1"
dest=$prefix/"$1"
if [ ! -e "$source" ] ; then
echo Error, source directory "$source" not found 1>&2
return 1
fi
if [ -d "$dest" ] ; then
return 0;
fi
echo Creating directory at "$dest" 1>&2
mkdir -p "$dest" || return $?
chmod --reference="$source" "$dest" || return $?
chown --reference="$source" "$dest"
return $?
}
function install_file ()
{
source="$1"
dest=$prefix/"$1"
if [ ! -e "$source" ] ; then
echo Error, source file "$source" not found 1>&2
return 1
fi
if [ -e "$dest" ] ; then
if [ -d "$dest" ] ; then
# Work around a docker behaviour:
#
# if we try to bind mount a single config file from the host
# to the container, and the file does not exist, then docker
# will create it... as a directory.
#
# This can happen if we "atomic run" the image before "atomic
# install", so detect that and fix it up here.
rmdir --ignore-fail-on-non-empty "$dest" || return 1
if [ -d "$dest" ] ; then
echo Failed to install file at "$dest", directory in the way 1>&2
return 1
fi
echo Installing file at "$dest" in place of existing empty directory 1>&2
else
cmp --silent "$source" "$dest" && return 0
# Attempting to install over an existing file with new contents?
# Copy to a predictable alternative instead, similar to ".rpmnew"
echo Installing over file "$dest", new file placed in "$dest".atomicnew 1>&2
cp -af "$source" "$dest".atomicnew || return 1
return 0;
fi
fi
echo Installing file at "$dest" 1>&2
cp -a "$source" "$dest" || return $?
return $?
}
install_dir /etc/pki
install_dir /etc/pki/rsyslog
install_dir /etc/rsyslog.d
install_file /etc/rsyslog.conf
install_file /etc/sysconfig/rsyslog
install_file /etc/logrotate.d/syslog
chcon -t etc_t "$prefix"/etc/logrotate.d/syslog
# rsyslog's logrotate script expects all its log files to exist
# already, even if they are only empty and not actively in use.
#
# So prepopulate the log files in the same way as the rpm .spec file's
# %post section.
for n in "$prefix"/var/log/{messages,secure,maillog,spooler}
do
[ -f $n ] && continue
umask 066 && touch $n
done