-
Notifications
You must be signed in to change notification settings - Fork 5
/
install.sh
executable file
·80 lines (61 loc) · 2.45 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
#!/bin/bash
function die {
echo "$1" >&2
exit 1
}
[ "`id -u`" -eq 0 ] || die "Aborted: this action requires root (sudo) access"
#create a username 'softioc' (used in an IOC's config) if it doesn't exist
id softioc &> /dev/null || useradd softioc
#copy source files to $INSTALLDIR
INSTALLDIR=/usr/local/systemd-softioc
[ -d $INSTALLDIR ] || install -d -m755 "$INSTALLDIR" || die "Failed to create $INSTALLDIR"
cp ./epics-softioc.conf $INSTALLDIR
cp ./library.sh $INSTALLDIR
cp ./manage-iocs $INSTALLDIR
[ $? -ne 0 ] && die "Failed to copy files to $INSTALLDIR"
echo "Source files are successfully copied to $INSTALLDIR. See below:"
ls -lht $INSTALLDIR
#install epics-softioc.logrotate
if [ -d /etc/logrotate.d ]; then
cp epics-softioc.logrotate /etc/logrotate.d || echo "Failed to setup logrotate"
fi
#'manage-iocs' is a symbolic link
SYMLINK=/usr/bin/manage-iocs
if [ -f $SYMLINK -a "$(readlink -f $SYMLINK)" != $INSTALLDIR/manage-iocs ]; then
ls -lh $SYMLINK
die "There is already a symlink: $SYMLINK->$(readlink -f $SYMLINK). \
Please manually remove it. Then type 'sudo ./install.sh' to reinstall this package"
fi
printf "\nCreating the symlink $SYMLINK ...\n"
rm -f $SYMLINK || die "Failed to remove $SYMLINK"
ln -s $INSTALLDIR/manage-iocs $SYMLINK || die "Failed to create $SYMLINK"
printf "Successfully created the symlink: $SYMLINK -> $(readlink -f $SYMLINK)\n\n"
#get, build and install procServ
which procServ > /dev/null 2>&1
if [ $? -eq 0 ]; then
read -p "procServ is already installed. \
Do you want to remove it and install a new one? Type 'yes' if you do. " answer
[ ! "$answer" = "yes" ] && die "Done."
fi
distID="$(cat /etc/os-release | grep "^ID=" | cut -d '=' -f2)"
if [ "$distID" == "\"centos\"" ] || [ "$distID" == "debian" ]; then
read -p "There is a package for 'procServ'. You may manually install it. \
Do you still want to build procServ from github? Type 'yes' if you do" answer
[ ! "$answer" = "yes" ] && die "Done."
fi
PROCSERVGIT="https://github.com/ralphlange/procServ.git"
PROCSERVDIR=/tmp/procServ
cd /tmp
[ -d $PROCSERVDIR ] && { rm -fR $PROCSERVDIR || die "Failed to remove $PROCSERVDIR"; }
echo "Building procServ from github..."
git clone $PROCSERVGIT
cd procServ
make
./configure --disable-doc
make
if [ -f procServ ]; then
cp procServ /usr/bin || die "Failed to copy procServ to /usr/bin"
else
die "Failed to build procServ in $PROCSERVDIR"
fi
printf "\n\nSuccessfully installed procServ to /usr/bin\n\n"