-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup
executable file
·86 lines (66 loc) · 1.77 KB
/
setup
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
#!/bin/bash
source "/data/SetupHelper/CommonResources"
pythonLibs="$scriptDir/ext"
packageLogFile="/var/log/BatteryAggregator/current"
extInstall ()
{
url=$1
project=$2
branch=$3
repoPath=$4
if [ -z "$branch" ]; then
branch="master"
fi
if [ -z "$repoPath" ]; then
repoPath="$project"
fi
logMessage "++ Install Python library $project ($branch) from $url into $pythonLibs"
wget "$url/archive/refs/heads/$branch.zip" -O "/tmp/$project.zip"
if [ $? -ne 0 ]; then
logMessage "++ Failed to download $project ($branch) from $url"
exit 1
fi
mkdir -p "/tmp/$project"
unzip -oq "/tmp/$project.zip" -d "/tmp/$project"
if [ "$repoPath" == "/" ]; then
# don't quote - need shell expansion!
cp -R /tmp/$project/$project-$branch/* "$pythonLibs"
else
rm -fr "$pythonLibs/$project"
mv "/tmp/$project/$project-$branch/$repoPath" "$pythonLibs/$repoPath"
fi
rm -fr "/tmp/$project" "/tmp/$project.zip"
}
extUninstall ()
{
logMessage "++ Removing Python libray $1"
rm -fr "$pythonLibs/$1"
}
prompt ()
{
/bin/echo -n "$*"
read response
}
#### running manually and OK to proceed - prompt for input
if [ $scriptAction == 'NONE' ] ; then
# display initial message
echo
echo "Battery Aggregator"
standardActionPrompt
fi
#### install code goes here
if [ $scriptAction == 'INSTALL' ] ; then
logMessage "++ Installing Battery Aggregator service"
opkg update
opkg install python3-pip python3-pydoc
mkdir -p "$pythonLibs"
extInstall "https://github.com/pulquero/velib_python" "velib_python" "master" "/"
installService $packageName
fi
#### uninstalling - check scriptAction again
# if an install step failed package needs to be removed
if [ $scriptAction == 'UNINSTALL' ] ; then
logMessage "++ Uninstalling Battery Aggregator service"
removeService $packageName
fi
endScript