This repository was archived by the owner on Oct 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
143 lines (113 loc) · 6.62 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/env bash
INSTALLPATH="/opt/PiNet-Screens"
if [[ "$(id -u)" != "0" ]]; then #Check if script is being run as root
echo $"This script must be run with sudo bash" 1>&2
exit 1
fi
if [[ ! "$BASH_VERSION" ]] ; then #Checks that PiNet is being run using bash and not ash (aka sh)
whiptail --title $"Shell error" --msgbox $"Please do not run PiNet with sudo sh $0. Please run it with bash using sudo bash $0" 8 78
echo $"Please do not run PiNet Screens installer with sh $0. Please run it with bash using sudo bash $0" 1>&2
exit 1
fi
ReplaceAnyTextOnLine(){
# ReplaceTextLine /textfile bob brian
#REMEMBER!! The & symbol can't be in any of the strings as SED is using it for separating. Can change it if need be
egrep -i "$2" $1 >> /dev/null
if [ $? -eq 0 ]; then
sed -i "s&.*$2.*&$3&g" $1
return 0
else
echo "$3" >> $1
return 1
fi
}
LOGO=$(cat <<-END
[49m[K[0m[24C[48;5;231m [49m
[22C[48;5;231m [48;5;188m [48;5;16m [48;5;231m [49m
[22C[48;5;231m [48;5;16m [48;5;149m [48;5;155m [48;5;16m [48;5;102m [48;5;231m [49m
[19C[48;5;231m [48;5;16m [48;5;231m [49m
[8C[48;5;231m [2C [48;5;16m [48;5;231m [49m
[6C[48;5;231m [48;5;16m [48;5;231m [48;5;16m [48;5;149m [48;5;16m [48;5;231m [48;5;16m [48;5;231m [49m
[5C[48;5;231m [48;5;16m [48;5;149m [48;5;58m [48;5;16m [48;5;149m [48;5;16m [48;5;149m [48;5;16m [48;5;231m [49m
[5C[48;5;231m [48;5;16m [48;5;58m [48;5;149m [48;5;16m [48;5;231m [48;5;16m [48;5;231m [48;5;16m [48;5;149m [48;5;16m [48;5;231m [49m
[5C[48;5;231m [48;5;16m [48;5;231m [48;5;16m [48;5;188m [48;5;231m [48;5;188m [48;5;16m [48;5;231m [49m
[4C[48;5;231m [48;5;16m [48;5;168m [48;5;53m [48;5;16m [48;5;231m [48;5;16m [48;5;59m [48;5;231m [49m
[2C[48;5;231m [48;5;102m [48;5;145m [48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [49m
[48;5;231m [48;5;16m [48;5;168m [48;5;204m [48;5;16m [48;5;231m [48;5;16m [48;5;89m [48;5;168m [48;5;16m [48;5;102m [48;5;16m [48;5;168m [48;5;204m [48;5;16m [48;5;188m [48;5;231m [49m
[48;5;231m [48;5;16m [48;5;132m [48;5;168m [48;5;52m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [49m
[48;5;231m [48;5;16m [48;5;204m [48;5;168m [48;5;16m [48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [48;5;145m [48;5;16m [48;5;231m [49m
[1C[48;5;231m [48;5;16m [48;5;145m [48;5;231m [48;5;16m [48;5;204m [48;5;168m [48;5;16m [48;5;231m [48;5;16m [48;5;231m [49m
[3C[48;5;231m [48;5;16m [48;5;231m [48;5;16m [48;5;131m [48;5;168m [48;5;16m [48;5;59m [48;5;16m [48;5;168m [48;5;204m [48;5;16m [48;5;231m [49m
[3C[48;5;231m [48;5;16m [48;5;168m [48;5;204m [48;5;16m [48;5;231m [48;5;16m [48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;145m [48;5;231m [49m
[3C[48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [48;5;16m [48;5;145m [48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [49m
[3C[48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [48;5;16m [48;5;204m [48;5;168m [48;5;204m [48;5;16m [48;5;231m [48;5;16m [48;5;231m [49m
[3C[48;5;231m [48;5;16m [48;5;168m [48;5;89m [48;5;16m [48;5;231m [48;5;16m [48;5;53m [48;5;168m [48;5;52m [48;5;16m [48;5;231m [49m
[4C[48;5;231m [48;5;188m [48;5;16m [48;5;145m [48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [49m
[7C[48;5;231m [1C [48;5;16m [48;5;168m [48;5;204m [48;5;16m [48;5;231m [49m
[15C[48;5;231m [48;5;16m [48;5;168m [48;5;16m [48;5;231m [49m
[16C[48;5;231m [48;5;16m [48;5;231m [49m
[19C[48;5;231m [0m
END
)
echo "$LOGO"
echo ""
echo ""
echo "#################################################################################################################"
echo "This script will install the PiNet screens application."
echo "Note that the defaults used by the application assume the only PiNet Pis being used are used for display screens."
read -r -p "Are you sure? [y/N] " response
case "$response" in
[yY][eE][sS]|[yY])
echo "Installing..."
;;
*)
exit 1
;;
esac
cd ../
if [[ -d "$INSTALLPATH" ]]; then
cd $INSTALLPATH
git pull
else
git clone https://github.com/PiNet/PiNet-Screens /opt/PiNet-Screens
fi
if [[ ! -f ${INSTALLPATH}/pinet_screens/secrets/config.py ]]; then
cp ${INSTALLPATH}/pinet_screens/secrets/config_example.py ${INSTALLPATH}/pinet_screens/secrets/config.py
else
echo "Config file already exists, not overriding at ${INSTALLPATH}/pinet_screens/secrets/config.py"
fi
echo "Installing required packages..."
sudo apt install authbind -y
pip3 install -r ${INSTALLPATH}/pinet_screens/requirements.txt
(cd ${INSTALLPATH}/pinet_screens/ && sudo python3 create_user.py)
echo "Adding pinetscreens user..."
useradd -r pinetscreens
sudo chown -R pinetscreens:pinetscreens /opt/PiNet-Screens/
rm -f /etc/systemd/system/pinetscreens.service
cp $INSTALLPATH/scripts/pinetscreens.service /etc/systemd/system/pinetscreens.service
touch /etc/authbind/byport/80
chown pinetscreens:pinetscreens /etc/authbind/byport/80
chmod 755 /etc/authbind/byport/80
# Setup shared folder that is used
mkdir /home/shared/screens
mkdir /home/shared/screens/scripts/
chown pinetscreens:pinetscreens /home/shared/screens
chown :pinetscreens /opt/ltsp/armhf/etc/lts.conf
chmod 664 /opt/ltsp/armhf/etc/lts.conf
chmod 0700 /home/shared/screens
ReplaceAnyTextOnLine /usr/local/bin/bindfs-mount "/home/shared/screens" "bindfs -o perms=0775,force-group=teacher /home/shared/screens /home/shared/screens"
echo ""
echo "######################"
echo "Starting PiNet Screens"
echo "######################"
echo ""
systemctl daemon-reload
systemctl start pinetscreens
systemctl enable pinetscreens
su -c "sensible-browser localhost" - $SUDO_USER &
echo ""
echo "######################"
echo "Installation Complete!"
echo "######################"
echo ""
echo "You can access PiNet Screens by navigating to localhost in a web browser, or this machines IP address from another computer on the network"