-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjscripts
More file actions
executable file
·163 lines (152 loc) · 4.61 KB
/
jscripts
File metadata and controls
executable file
·163 lines (152 loc) · 4.61 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/sh
version=4.0
distrosite=http://www.rkrweb.nl/jscripts
localdir=/usr/local/sbin
# Build a new distribution set
buildDistro() {
# Clean versions.txt
if [ -e versions.txt ]; then
rm versions.txt
fi
# Process all files
while read line
do
jscript=`echo ${line} | cut -d "=" -f 1`
version=`grep -m1 'version=' src/${jscript} | cut -d "=" -f 2`
echo "Processing ${jscript} version ${version}"
cd src
tar czf ../distro/${jscript}.${version}.tgz ${jscript}
echo "${jscript}:${version}" >> ../versions.txt
cd ..
done < filelist
jscript=jscripts
version=`grep -m1 'version=' ${jscript} | cut -d "=" -f 2`
echo "Processing ${jscript} version ${version}"
tar czf distro/${jscript}.${version}.tgz ${jscript}
cp distro/${jscript}.${version}.tgz distro/${jscript}.tgz
echo "${jscript}:${version}" >> versions.txt
mv versions.txt distro
}
# Update all scripts
updateScripts() {
cd ${localdir}
wget -v ${distrosite}/versions.txt -O versions.txt
while read line
do
jscript=`echo ${line} | cut -d ":" -f 1`
if [ -e ${jscript} ]; then
jscriptversion=`grep -m1 'version=' ${jscript} | cut -d "=" -f 2`
else
jscriptversion=unknown
fi
distroversion=`echo ${line} | cut -d ":" -f 2`
if [ ! "${jscriptversion}" == "${distroversion}" ]
then
wget -v ${distrosite}/${jscript}.${distroversion}.tgz -O ${jscript}.${distroversion}.tgz
tar xzf ${jscript}.${distroversion}.tgz
chmod +x ${jscript}
chown root:root ${jscript}
echo "Updated ${jscript} to version ${distroversion}"
fi
done < versions.txt
}
# Update all scripts
refreshScripts() {
cd ${localdir}
wget -v ${distrosite}/versions.txt -O versions.txt
while read line
do
jscript=`echo ${line} | cut -d ":" -f 1`
distroversion=`echo ${line} | cut -d ":" -f 2`
wget -v ${distrosite}/${jscript}.${distroversion}.tgz -O ${jscript}.${distroversion}.tgz
tar xzf ${jscript}.${distroversion}.tgz
chmod +x ${jscript}
chown root:root ${jscript}
echo "Refreshed script ${jscript} to version ${distroversion}"
done < versions.txt
jscript="jscripts"
distroversion=`grep -m1 'jscripts:' versions.txt| cut -d ":" -f 2`
wget -v ${distrosite}/${jscript}.${distroversion}.tgz -O ${jscript}.${distroversion}.tgz
tar xzf ${jscript}.${distroversion}.tgz
chmod +x ${jscript}
chown root:root ${jscript}
echo "Refreshed script ${jscript} to version ${distroversion}"
}
# Update jscripts script
updateJscripts() {
cd ${localdir}
wget -v ${distrosite}/versions.txt -O versions.txt
jscript="jscripts"
distroversion=`grep -m1 'jscripts:' versions.txt| cut -d ":" -f 2`
jscriptversion=`grep -m1 'version=' ${jscript} | cut -d "=" -f 2`
if [ ! "${jscriptversion}" == "${distroversion}" ]; then
wget -v ${distrosite}/${jscript}.${distroversion}.tgz -O ${jscript}.${distroversion}.tgz
tar xzf ${jscript}.${distroversion}.tgz
chmod +x ${jscript}
chown root:root ${jscript}
echo "Updated ${jscript} to version ${distroversion}"
fi
}
# List versions
versionList() {
cd ${localdir}
wget -v ${distrosite}/versions.txt -O versions.txt
while read line
do
jscript=`echo ${line} | cut -d ":" -f 1`
if [ -e ${jscript} ]; then
jscriptversion=`grep -m1 'version=' ${jscript} | cut -d "=" -f 2`
else
jscriptversion=unknown
fi
distroversion=`echo ${line} | cut -d ":" -f 2`
echo "Latest version of ${jscript}: ${distroversion}"
echo "Installed version of ${jscript}: ${jscriptversion}"
echo " "
done < versions.txt
}
# List versions
cleanFiles() {
cd ${localdir}
wget -v ${distrosite}/versions.txt -O versions.txt
while read line
do
jscript=`echo ${line} | cut -d ":" -f 1`
rm -f ${jscript}*tgz
done < versions.txt
}
# Show help
showHelp() {
echo "+--------------------------------------------------------+"
echo "| jscripts version ${version}, written by Rene Kreijveld |"
echo "+--------------------------------------------------------+"
echo "| Options: |"
echo "| $0 versions: list all versions |"
echo "| $0 update: update scripts |"
echo "| $0 refresh: refresh scripts |"
echo "| $0 update_jscripts: update jscripts script |"
echo "| $0 clean: remove .tgz files |"
echo "| $0 help: show this help |"
echo "+--------------------------------------------------------+"
}
echo "jscripts version ${version}, written by Rene Kreijveld"
# Process option
case "$1" in
distro) buildDistro;
;;
update) updateScripts;
;;
refresh) refreshScripts;
;;
update_jscripts) updateJscripts;
;;
versions) versionList;
;;
clean) cleanFiles;
;;
help) showHelp;
;;
*) showHelp;
exit 0;
;;
esac