forked from km4ack/73Linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
73.sh
executable file
·286 lines (247 loc) · 8.67 KB
/
73.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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#! /bin/bash
echo "#######################################"
echo "# Welcome to 73 Linux #"
echo "#######################################"
#variables
BAPDIR="$(cd "$(dirname "$0")" && pwd)"
BAPSYSINFO=${BAPDIR}/cache/cpu.bap
BAPPVER=$(cat ${BAPDIR}/changelog | head -1 | sed 's/version=//')
LOGO=${BAPDIR}/data/logo.png
TEMPCRON=/run/user/$UID/tempcron.txt
APPLIST=${BAPDIR}/cache/app-list.bap
APPPATH=${BAPDIR}/app/stable/
BAPINSTALL=${BAPDIR}/cache/install-path.bap
BUILDDIR=$HOME/.bap-source-files
export BUILDDIR
export LOGO
export BAPDIR
if [ ! -d ${BAPDIR}/cache ]; then
mkdir ${BAPDIR}/cache
fi
echo "#############################"
echo "Checking for 73 Linux Updates"
echo "#############################"
LATEST=$(curl -s https://raw.githubusercontent.com/km4ack/73Linux/master/changelog | head -1 | sed 's/version=//')
CURRENT=$(grep version ${BAPDIR}/changelog | head -1 | sed 's/version=//')
if (($(echo "${LATEST} ${CURRENT}" | awk '{print ($1 > $2)}'))); then
echo "#################################"
echo "A newer version of 73 Linux Found"
echo "Current version is $CURRENT"
echo "Latest version is $LATEST"
echo "############################"
yad --width=300 --height=150 --fixed --text-align=center --center --title="73 Linux" \
--image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \
--text "Updated version of 73 Linux found.\rInstalled - v${CURRENT}\rLatest - v${LATEST}\rWould you like to update?" \
--button="Yes":2 \
--button="No":3
BUT=$?
if [ $BUT = 252 ]; then
exit
elif [ $BUT = 2 ]; then
wget -q --tries=5 --timeout=10 --spider http://google.com #| yad --center --progress --pulsate --timeout-indicator=top --auto-close --no-buttons --text="Checking internet connection"
if [[ $? -eq 1 ]]; then
yad --center --timeout=3 --timeout-indicator=top --no-buttons --text="You are not connected to the internet"
exit
fi
cd $HOME
rm -rf 73Linux
git clone https://github.com/km4ack/73Linux.git
yad --width=300 --height=150 --fixed --text-align=center --center --title="73 Linux" \
--image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \
--text "Update complete.\rPlease restart 73 Linux" \
--button=gtk-ok
exit
fi
else
echo "73 Linux up to date. Version $CURRENT installed"
fi
echo "Checking for updated bap files"
CUR=$(grep version ${BAPDIR}/app/.bap-version | sed 's/version=//')
LATEST=$(curl -s https://raw.githubusercontent.com/km4ack/73Linux/master/app/.bap-version | grep version | head -1 | sed 's/version=//')
if (($(echo "${LATEST} ${CUR}" | awk '{print ($1 > $2)}'))); then
echo "#######################################"
echo "# Downloading latest bap files #"
echo "#######################################"
cd /run/user/$UID
git init 73Linux
cd 73Linux
git remote add -f origin https://github.com/km4ack/73Linux.git
git config pull.ff only
git config core.sparseCheckout true
echo "/app" >> .git/info/sparse-checkout
git pull origin master
cp -r /run/user/$UID/73Linux/app ${BAPDIR}/
rm -rf /run/user/$UID/73Linux
else
echo "bap files up to date"
fi
cd ${BAPDIR}
echo "#######################################"
echo "# Updating repository & verifying #"
echo "# a few needed items needed before #"
echo "# we begin. #"
echo "# #"
echo "# Enter your sudo password if asked #"
echo "#######################################"
sudo apt update
if ! hash yad 2>/dev/null; then
sudo apt install -y yad
fi
if ! hash jq 2>/dev/null; then
sudo apt install -y jq
fi
if ! hash bc >/dev/null; then
sudo apt install -y bc
fi
if ! hash git >/dev/null; then
sudo apt install -y git
fi
#####################################
# Verify not run as root
#####################################
if [ `whoami` = 'root' ]; then
yad --form --width=500 --text-align=center --center --title="73 Linux" --text-align=center \
--image ${LOGO} --window-icon=${LOGO} --image-on-top --separator="|" --item-separator="|" \
--text="<b>ROOT DETECTED</b>\rDon't run this script as root. \
Restart the script without sudo" \
--button=gtk-close
exit 1
fi
touch $HOME/.config/KM4ACK
#first run? welcome!
if [ ! -f "$BAPSYSINFO" ]; then
# Detect if the script is part of a full source checkout or standalone instead.
if [ ! -f "${BAPDIR}/app/stable/autohotspot" ]; then
echo -e "\n Missing important stuff. Can't continue. "
exit 1
fi
#create source repo
mkdir -p ${HOME}/.bap-source-files
#set the station call sign
N0CALL=$(yad --form --width=420 --text-align=center --title="73 Linux" --center \
--title="Amature Radio Callsign Required" --center --image="$LOGO" \
--field="Call Sign" \
--field="<b>Required</b>":LBL)
#input validate
TMPCALL=$(echo "${N0CALL^^}" | sed 's/||//' | awk '{gsub(/[^[:alnum:][:space:]]/,"?")} 1')
if echo "$TMPCALL" | grep -q "?";then
echo -e "\n ERROR: CRITICAL: valid call to operate (no SSID) $TMPCALL QRZ?"
exit 1
fi
#blank check
if [ $N0CALL = "||" ] || [ $N0CALL = "" ]; then
echo -e "\n ERROR: CRITICAL: need a radio call to operate, nothing heard QRZ?"
exit 1
else
#save
MYCALL=$TMPCALL
BAPCALL=$TMPCALL
touch ${BAPDIR}/MYCALL.$MYCALL
touch ${BAPDIR}/cache/MYCALL.$MYCALL
echo "###################################"
echo "#Registered $MYCALL to this host"
echo "###################################"
wait
fi
# Setup the other CPU data we will need make it global for this session
if [ -f ${BAPDIR}/bin/set-enviroment.sh ]; then
echo "###################################"
echo "#Detected New System for Install"
echo "###################################"
echo -e "Hostname - $(hostname -s)"
${BAPDIR}/bin/set-enviroment.sh
else
echo -e "\n ERROR: CRITICAL: check integrity of package."
exit 1
fi
# Show once dialog
yad --form --width=420 --height=200 --fixed --center --title="Welcome ${MYCALL}!" --image="$LOGO" \
--image-on-top --text-align=fill --button=gtk-ok --text="\n <b>${MYCALL} DE KM4ACK!</b>\r Welcome to\r
<b>73 Linux</b>\n
Build a Pi on Steroids!\n
-A full build can take up to 4 hours!
-Possibly more on a Pi 3
-Press ok to scan the system
and begin the build process"
#fi first run, wait
wait
#Give option to load community apps. Call config script
else
${BAPDIR}/bin/config.sh
fi
COMMUNITY_CK=$(ls -a ${BAPDIR}/cache/ | grep .community)
if [ -z $COMMUNITY_CK ]; then
echo "Community apps excluded"
else
echo "Community Apps included"
rm ${BAPDIR}/cache/.community
fi
#set up variables for use globally here
BAPARCH=$(echo $(sed '1q;d' $BAPSYSINFO))
BAPCORE=$(echo $(sed '2q;d' $BAPSYSINFO))
BAPCPU=$(echo $(sed '3q;d' $BAPSYSINFO))
BAPDIST=$(echo $(sed '4q;d' $BAPSYSINFO))
BAPSRC=$(echo ${HOME}/.bap-source-files)
echo $BAPDIR > $BAPINSTALL
BAPCALL=$(ls ${BAPDIR}/cache | grep MYCALL.* | sed 's/MYCALL.//')
MYCALL=$BAPCALL
CALL=$BAPCALL
#LOAD_FILES=$(echo $BAPCPU | grep arm)
#Determine if to include community apps
#if [ -z "$LOAD_FILES" ] && [ -n "$COMMUNITY_CK" ]; then
# APPSFILES="${BAPDIR}/app/stable/x86_64/*.bapp ${BAPDIR}/app/community/x86_64/*.bapp"
#elif [ -z $LOAD_FILES ]; then
# APPSFILES="${BAPDIR}/app/stable/x86_64/*.bapp"
#elif [ -n $LOAD_FILES ] && [ -n "$COMMUNITY_CK" ]; then
# APPSFILES="${BAPDIR}/app/stable/pi/*.bapp ${BAPDIR}/app/community/pi/*.bapp"
#elif [ -n $LOAD_FILES ]; then
# APPSFILES="${BAPDIR}/app/stable/pi/*.bapp"
#fi
LOAD_FILES=$(lscpu | grep Architecture: | awk '{print $2}')
case $LOAD_FILES in
armv7l)
if [ -n "$COMMUNITY_CK" ]; then
APPSFILES="${BAPDIR}/app/stable/pi/*.bapp ${BAPDIR}/app/community/pi/*.bapp"
else
APPSFILES="${BAPDIR}/app/stable/pi/*.bapp"
fi;;
aarch64)
if [ -n "$COMMUNITY_CK" ]; then
APPSFILES="${BAPDIR}/app/stable/pi/*.bapp ${BAPDIR}/app/community/pi/*.bapp"
else
APPSFILES="${BAPDIR}/app/stable/pi/*.bapp"
fi;;
x86_64)
if [ -n "$COMMUNITY_CK" ]; then
APPSFILES="${BAPDIR}/app/stable/x86_64/*.bapp ${BAPDIR}/app/community/x86_64/*.bapp"
else
APPSFILES="${BAPDIR}/app/stable/x86_64/*.bapp"
fi;;
esac
export BAPCPU
export BAPCORE
export BAPARCH
export BAPDIST
export BAPCALL
export MYCALL
export CALL
export BAPSRC
export BAPSYSINFO
export BAPPVER
export APPSFILES
export TEMPCRON
export LOGO
#check for updates
${BAPDIR}/bin/app-check.sh
wait
#jump to uninstall
UNINSTALL_CK=$(ls -a ${BAPDIR}/cache/ | grep .remove)
if [ -n "$UNINSTALL_CK" ]; then
rm ${BAPDIR}/cache/.remove
${BAPDIR}/bin/remove.sh
wait
exit
fi
#launch menu
${BAPDIR}/bin/menu.sh
wait