-
Notifications
You must be signed in to change notification settings - Fork 49
/
install.sh
executable file
·57 lines (46 loc) · 1.42 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
#!/bin/bash
echo
echo
if [ $UID != 0 ]; then
echo "You must run this with the sudo command or as root..."
exit
fi
# Set a default home
PYHOME="/home/pytomation"
if [ "x$1" == "x" ]; then
echo "You are using the default install location..."
echo "You can change this by running install.sh with an path..."
echo "Example: install.sh /usr/local/lib/pytomation"
fi
echo -n "Install location is -> $PYHOME [Y/n] ?"
read a
if [ "x$a" == "xn" ] || [ "x$a" == "xN" ]; then
exit
fi
echo "Creating user pyto..."
useradd -m -d $PYHOME pyto
if [ ! -d $PYHOME ]; then
mkdir $PYHOME
fi
echo "Copying files to $PYHOME..."
cp -a * $PYHOME
chown -R pyto $PYHOME
OLD_INIT_SCRIPT="/etc/init.d/pyto"
NEW_INIT_SCRIPT="/etc/init.d/pytomation"
if [ -e "$OLD_INIT_SCRIPT" ]; then
echo "Removing old init script at $OLD_INIT_SCRIPT ..."
rm "$OLD_INIT_SCRIPT"
fi
echo "Copying init script to /etc/init.d..."
cp pytomation.init "$NEW_INIT_SCRIPT"
echo "Making sure scripts are excutable..."
chmod +x "$NEW_INIT_SCRIPT"
# Old versions of the install script created a manual rcS symlink for runlevel
# 2 only, which is not correct. Force remove any old symlinks that might exist
# before using update-rc.d to create the proper entries (start or kill) at all
# runlevels.
echo "Removing old rcS entries ..."
update-rc.d -f pyto remove
echo "Configuration Pytomation to run at boot ..."
update-rc.d pytomation defaults
echo "Finished..."