-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·96 lines (93 loc) · 2.7 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·96 lines (93 loc) · 2.7 KB
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
#!/bin/bash
clear
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
NODE="$(which node)"
echo " _ _____ _"
echo "(_) ___| | |"
echo " _\ \`--. _ __ ___ ___ __| |"
echo "| |\`--. \\ \\'_\\ / _ \\/ _ \\/ _\` |"
echo "| /\__/ / |_) | __/ __/ (_| |"
echo "|_\____/| .__/ \___|\___|\__,_|"
echo " | |"
echo " |_| Logger"
echo "(c) Jonathan Guenther 2017"
echo "v0.0.1"
printf "\n"
echo "USE AT YOUR OWN RISK!"
printf "-------------------------------\n"
echo "checking if setup already run"
if [ -z "$NODE" ]
then
echo "Couldn't find NodeJS! Please check your setup before you continue!"
exit 1
fi
if [ -d $DIR/node_modules ]
then
echo "node_folder found!"
if npm ls | grep -q google-spreadsheet && npm ls | grep -q speedtest-net; then
echo "required modules found!"
else
echo "couldn't find required dependencies"
while true; do
read -p "Do you wish to install them now?" yn
case $yn in
[Yy]* ) npm install; break;;
[Nn]* ) echo "cannot continue without dependencies!";exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
else
echo "couldn't find required dependencies"
while true; do
read -p "Do you wish to install them now? " yn
case $yn in
[Yy]* ) npm install; break;;
[Nn]* ) echo "cannot continue without dependencies!";exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
echo "-------------------------------\n"
if [ -e $DIR/client_secret.json ]
then
echo "client_secret.json already exists, skipping step"
else
while true; do
read -p 'Please state the ABSOLUTE location of your credentials JSON > ' cred
echo $cred
cp $cred $DIR/client_secret.json && break|| echo "Error while reading file! Please try again!"
done
fi
echo "\n"
read -p "Please enter your Google Sheets ID(Or leave empty to skip) >" gid
if [ ! $gid = "" ]
then
sed -i "2s/.*/return '$gid';/" $DIR/gid.js
else
echo "skipping Step"
fi
printf "-------------------------------\n"
echo "checking connection"
CHECK="$($NODE $DIR/test.js)"
if [[ $CHECK == "error"* ]]
then
echo "Couldn't establish connection."
printf "Reason:\n %s" "$CHECK"
echo "Please check your setup and restart this script."
exit 1
else
printf "Connection successfully established!"
rm $DIR/test.js
fi
printf "-------------------------------\n"
while true; do
read -p "Do you wish to install as a cronjob? " yn
case $yn in
[Yy]* ) crontab -l | { cat; echo "*/5 * * * * $NODE $DIR/app.js"; } | crontab -; echo "Script is now live!";break;;
[Nn]* ) echo "Not adding to cronjob.";exit;;
* ) echo "Please answer yes or no.";;
esac
done
printf "\n"
echo "Thanks for using this script."