-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
60 lines (53 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
52
53
54
55
56
57
58
59
60
if [[ $EUID -ne 0 ]]; then
echo "I need sudo right. plz (insert cute cat image)"
exit 1
fi
UPDATE=""
USERID=""
while getopts ":u:I:" opt; do
case "$opt" in
u) UPDATE="$OPTARG"
;;
I) USERID="$OPTARG"
;;
esac
done
if [ "N" != "$UPDATE" ]; then
echo "updating..."
sudo apt-get -qq update
sudo apt-get -qq install curl python-setuptools python-dev build-essential python-pip
sudo -H pip install --upgrade pip > /dev/null
sudo -H pip install --upgrade virtualenv > /dev/null
sudo -H pip install pyBarcode > /dev/null
echo "done updating"
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
mkdir "$DIR/smartfridge"
echo "downloading the code..."
curl -Ls "https://api.github.com/repos/arendjan/pws/tarball" > "$DIR/smartfridge/GIT.tar.gz"
echo "done downloading"
echo "unzipping and putting the files in the correct place..."
mkdir -m 777 $DIR/smartfridge/temp
tar -xzf "$DIR/smartfridge/GIT.tar.gz" -C "$DIR/smartfridge/temp"
cp -rf "$DIR"/smartfridge/temp/*/raspberry/* "$DIR/smartfridge"
cp -rf "$DIR/smartfridge/start.py" "$DIR/start.py"
rm -rf "$DIR/smartfridge/temp"
rm -rf "$DIR/smartfridge/GIT.tar.gz"
sudo chmod -R 777 "$DIR/smartfridge/"
sudo chmod -R 777 "$DIR/smartfridge/printjobs"
echo "done"
echo "setting up a cronjob"
#write out current crontab
crontab -l > mycron
#echo new cron into cron file
echo "@reboot sudo python $DIR/start.py" >> mycron
#install new cron file
crontab mycron
rm mycron
echo "done setting up the cronjob"
if [ ! -z "$USERID" ]; then
echo "setting up your settings file"
echo $'userId="'$USERID$'"\ninterval=5\nurl="http://pws.svshizzle.com/api/"' > "$DIR/smartfridge/settings.py"
echo "Done writing"
fi
echo "Doei"