-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
51 lines (51 loc) · 1.69 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
#!/bin/bash
SCRIPTNAME="blinktemp"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
echo "Checking dependency requirements..."
if [ $(dpkg-query -W -f='${Status}' dos2unix 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
apt-get install -y dos2unix;
else
echo "---dos2unix already installed"
fi
if [ $(dpkg-query -W -f='${Status}' python2.7-dev 2>/dev/null | grep -c "ok installed") -eq 0 ]; then
apt-get install -y python-pip python2.7-dev;
easy_install pip;
echo "---python installed"
else
echo "---python2.7-dev already installed"
fi
if [ $(pydoc modules | grep -c "blinkstick") -eq 0 ]; then
pip install blinkstick;
echo "---blinkstick python module installed"
else
echo "---blickstick python module already installed."
fi
if [ $(pydoc modules | grep -c "psutil") -eq 0 ]; then
pip install psutil;
else
echo "---psutil python system monitor already installed."
fi
echo "Copying scripts..."
dos2unix ./$SCRIPTNAME.py
echo "--removed windows cr:lf $SCRIPTNAME.py"
dos2unix ./$SCRIPTNAME.sh
echo "--removed windows cr:lf $SCRIPTNAME.sh"
chmod 755 ./$SCRIPTNAME.py
echo "--adjusted permissions $SCRIPTNAME.py"
chmod 755 ./$SCRIPTNAME.sh
echo "--adjusted permissions $SCRIPTNAME.sh"
cp ./$SCRIPTNAME.sh /etc/init.d
echo "--copied $SCRIPTNAME.sh to /etc/init.d"
mkdir /usr/local/bin/$SCRIPTNAME
cp ./$SCRIPTNAME.py /usr/local/bin/$SCRIPTNAME
echo "--copied $SCRIPTNAME.py to /usr/local/bin/$SCRIPTNAME"
chmod 755 /etc/init.d/$SCRIPTNAME.sh
echo "--adjusted permissions $SCRIPTNAME.sh"
update-rc.d $SCRIPTNAME.sh defaults
echo "--service $SCRIPTNAME installed"
/etc/init.d/$SCRIPTNAME.sh start
systemctl start $SCRIPTNAME
echo "--service $SCRIPTNAME started"