forked from OpenSurv/OpenSurv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·114 lines (93 loc) · 3.2 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
#!/bin/bash
if [ ! "$BASH_VERSION" ] ; then
echo "ERROR: Please use bash not sh or other shells to run this installer. You can also run this script directly like ./install.sh"
exit 1
fi
show_version() {
grep fullversion_for_installer "$BASEPATH/surveillance/surveillance.py" | head -n 1 | cut -d"=" -f2
}
configure_lightdm() {
echo '[Seat:*]
autologin-user=opensurv
#autologin-session=xfce
autologin-session=opensurv
autologin-user-timeout=0' > /etc/lightdm/lightdm.conf
}
set_default_options_mpv() {
#mpv logging may really fill your disk fast, as a precaution only log fatal errors by default
echo 'msg-level=all=fatal' > /home/opensurv/.config/mpv/mpv.conf
}
if [ "$(id -u)" -ne 0 ];then echo "ABORT, run this installer as the root user (sudo ./install.sh)"; exit 2; fi
BASEPATH="$(cd $(dirname "${BASH_SOURCE[0]}");pwd)"
echo "Use this installer on your own risk. Make sure this host does not contain important data and is replacable"
echo "This installer will configure to boot directly into Opensurv"
echo
echo -n "The following version will be installed:"
show_version
echo
echo "Do you want to continue press <Enter>, <Ctrl-C> to cancel"
read
#Install needed packages
apt update
apt install xdotool mpv xfce4 python3-pygame python3-xlib ffmpeg wmctrl unclutter -y
#Configure user and autologin
useradd -m opensurv -s /bin/bash
configure_lightdm
DESTPATH="/home/opensurv"
mkdir -pv "$DESTPATH"/{etc,lib,logs,bin}
SOURCEDIR="$BASEPATH/surveillance"
CONFDIR="etc"
BACKUPCONFDIR=/tmp/backup_opensurv_config_$(date +%Y%m%d_%s)
if [ -d "$DESTPATH/${CONFDIR}" ];then
echo
echo "Existing config dir will be backed up to "${BACKUPCONFDIR}""
cp -arv "$DESTPATH/${CONFDIR}" "${BACKUPCONFDIR}"
echo
echo "Do you want to overwrite your current config files with the example config files?"
echo "Type yes/no"
read USEEXAMPLECONFIG
else
USEEXAMPLECONFIG="yes"
fi
if [ -d /home/opensurv/lib/images ];then
echo
echo "Do you want to overwrite you current images directory (/home/opensurv/lib/images) with the images from the installer?"
echo "Type yes/no"
read OVERWRITESIMAGES
else
OVERWRITESIMAGES="yes"
fi
echo
echo "Do you want me to (re-)start opensurv after install?"
echo "Type yes/no"
read ANSWERSTART
if [ x"$OVERWRITESIMAGES" == x"yes" ]; then
rsync -av "$SOURCEDIR/images/" "$DESTPATH/lib/images/"
fi
if [ x"$USEEXAMPLECONFIG" == x"yes" ]; then
rsync -av "$SOURCEDIR/etc/" "$DESTPATH/etc/"
set_default_options_mpv
fi
rsync -av "$SOURCEDIR/demo" "$DESTPATH/lib/"
rsync -av "$SOURCEDIR/core" "$DESTPATH/lib/"
rsync -av "$SOURCEDIR/surveillance.py" "$DESTPATH/lib/"
rsync -av opensurv "$DESTPATH/bin/"
rsync -av opensurv.desktop "/usr/share/xsessions/"
chown -Rc opensurv:opensurv /home/opensurv
#Link config file dir into /etc as convenient way to edit
if [ ! -L /etc/opensurv ]; then
ln -fsv "$DESTPATH/$CONFDIR" /etc/opensurv
fi
if [ ! -f /home/opensurv/firstinstall_DONE ];then
#We use lightdm, do not let gdm3 be in our way
apt remove gdm3
touch /home/opensurv/firstinstall_DONE
echo "This is first install we need to reboot"
echo "For reboot press <Enter>"
read
reboot
fi
if [ x"$ANSWERSTART" == x"yes" ]; then
systemctl daemon-reload
systemctl restart lightdm
fi