-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·45 lines (36 loc) · 888 Bytes
/
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
#!/bin/sh
#Defining variable for launcher
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
launcher="${parent_path}/launcher.sh"
logFile="${parent_path}/logs/cronlog"
#Testing if logs folder exists
if [ -e "${parent_path}/logs" ]
then
echo "Folder logs already exists"
else
echo "Creating logs folder.."
mkdir ${parent_path}/logs
cd /
fi
#Adding Zeroconf API to crontab
add_cronjob () {
echo "Adding Zeroconf API as a cronjob"
crontab -l > newcron
echo "@reboot sh ${launcher} > $logFile 2>&1" >> newcron
crontab newcron
rm -f newcron
}
crontab -l | grep "$launcher"
if [ $? -eq 0 ]
then
echo "Job already added to crontab"
else
echo "Adding job to crontab..."
add_cronjob
fi
if [ -e $logFile ]
then
echo "File '$logFile' is already created"
else
echo "Please restart your raspberry pi to start the ZeroConfAPI"
fi