forked from iiab/iiab-factory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiiab
executable file
·469 lines (396 loc) · 23.5 KB
/
iiab
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
#!/bin/bash
# Copied from: https://github.com/iiab/iiab-factory/blob/master/iiab
# To install Internet-in-a-Box (IIAB) 7.2 / pre-release onto Raspberry Pi OS,
# Ubuntu 20.04, Linux Mint 20 or Debian 10, run this 1-line installer:
#
# curl d.iiab.io/install.txt | sudo bash
# 1. WARNING: NOOBS IS *NOT* SUPPORTED, as its partitioning is very different.
# On a Raspberry Pi, WE RECOMMEND YOU INSTALL THE LATEST RASPBERRY PI OS:
# https://www.raspberrypi.org/documentation/installation/installing-images/README.md
# To attempt IIAB 7.2 on another Linux see the full/manual instructions:
# https://github.com/iiab/iiab/wiki/IIAB-Installation#do-everything-from-scratch
# 2. An Ethernet cable is HIGHLY RECOMMENDED during installation, as this is
# more reliable than WiFi (and faster!) WARNING: IF YOU CONNECT YOUR IIAB'S
# INTERNAL WIFI TO THE INTERNET OVER 5 GHz, YOU'LL PREVENT OLDER LAPTOPS/
# PHONES/TABLETS (WHICH REQUIRE 2.4 GHz) FROM CONNECTING TO YOUR IIAB'S
# INTERNAL HOTSPOT. See: "wifi_up_down: True" in /etc/iiab/local_vars.yml
# 3. Run 'sudo raspi-config' on RPi, to set LOCALISATION OPTIONS
# 4. OPTIONAL: if you have slow/pricey Internet, pre-position KA Lite's
# mandatory 0.9 GB English Pack (en.zip) within /tmp -- you can grab a copy
# from http://pantry.learningequality.org/downloads/ka-lite/0.17/content/contentpacks/en.zip
# 5. WHEN YOU RUN 1-LINE INSTALLER 'curl d.iiab.io/install.txt | sudo bash'
# YOU THEN NEED TO TYPE IN YOUR PASSWORD IF ON UBUNTU/DEBIAN/ETC (for sudo)
# ^^^ ^^^^ ^^^^ ^^ ^^^^ ^^ ^^^^ ^^^^^^^^
# 6. Follow on-screen instructions (TYPE 'sudo iiab' TO RESUME IF EVER NECESS!)
# 7. About 1-2 hours later, it will announce that INTERNET-IN-A-BOX (IIAB)
# SOFTWARE INSTALL IS COMPLETE, prompting you to reboot...TO ADD CONTENT!
# Thanks For Building Your Own Library To Serve One & All
#
# DRAFT IIAB 7.2 Release Notes:
# https://github.com/iiab/iiab/wiki/IIAB-7.2-Release-Notes
#
# Write to bugs @ iiab.io if you find issues, Thank You! Special Thanks to the
# countries+communities+volunteers who worked non-stop to bring about IIAB 7.2!
#
# IIAB Development Team
# http://FAQ.IIAB.IO
set -e # Exit on error (avoids snowballing)
export DEBIAN_FRONTEND=noninteractive # Bypass (most!) interactive questions
FLAGDIR=/etc/iiab/install-flags
APTPATH=/usr/bin # Avoids problematic /usr/local/bin/apt on Linux Mint
[ $(id -un) = root ] || { echo "Please run 'sudo iiab'" ; exit 1 ; }
mkdir -p $FLAGDIR # Whih also creates /etc/iiab
# Save CLI params (PR #s) for section I. so 'sudo iiab' continues after reboots
[ $# != 0 ] && printf '%s\n' "$@" >> /etc/iiab/pr-queue
# A. Subroutine for B. and D. Returns true (0) if username ($1) exists with password ($2)
command -v grep &> /dev/null ||
$APTPATH/apt -y install grep # AVOID UX CLUTTER+DELAYS: 4 MORE BELOW!
check_user_pwd() {
# $meth (hashing method) is typically '6' which implies 5000 rounds
# of SHA-512 per /etc/login.defs -> /etc/pam.d/common-password
meth=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f2)
salt=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f3)
hash=$(grep "^$1:" /etc/shadow | cut -d: -f2 | cut -d$ -f4)
[ $(python3 -c "import crypt; print(crypt.crypt('$2', '\$$meth\$$salt'))") == "\$$meth\$$salt\$$hash" ]
}
# B. Ask for password change if pi/raspberry default remains
if check_user_pwd "pi" "raspberry"; then
echo -e "\n\nRaspberry Pi's are COMPROMISED often if the default password is not changed!\n"
echo -n "What password do you want for GNU/Linux user 'pi' ? "
read ans < /dev/tty # Whines but doesn't change password if [Enter]
echo pi:"$ans" | chpasswd || true # Overrides 'set -e'
fi
# C. Create user 'iiab-admin' (or any other, some prefer 'pi' or 'ubuntu') as nec, with default password
IIAB_ADMIN_USER=iiab-admin
tmp=$(grep '^iiab_admin_user:\s' /opt/iiab/iiab/vars/default_vars.yml 2> /dev/null | sed 's/^iiab_admin_user:\s\+\<//; s/#.*//; s/\s*$//')
if [ "$tmp" != "" ]; then IIAB_ADMIN_USER=$tmp; fi
tmp=$(grep '^iiab_admin_user:\s' /etc/iiab/local_vars.yml 2> /dev/null | sed 's/^iiab_admin_user:\s\+\<//; s/#.*//; s/\s*$//')
if [ "$tmp" != "" ]; then IIAB_ADMIN_USER=$tmp; fi
#[ $tmp ] && IIAB_ADMIN_USER=$tmp # SAME AS ABOVE
IIAB_ADMIN_PUBLISHED_PWD=g0adm1n
tmp=$(grep '^iiab_admin_published_pwd:\s' /opt/iiab/iiab/vars/default_vars.yml 2> /dev/null | sed 's/^iiab_admin_published_pwd:\s\+\<//; s/#.*//; s/\s*$//')
if [ "$tmp" != "" ]; then IIAB_ADMIN_PUBLISHED_PWD=$tmp; fi
#[ $tmp ] && IIAB_ADMIN_PUBLISHED_PWD=$tmp # SAME AS ABOVE
if ! grep -q '^iiab_admin_user_install:\s\+[fF]alse\b' /etc/iiab/local_vars.yml 2> /dev/null ; then
if ! id -u "$IIAB_ADMIN_USER" > /dev/null 2> /dev/null; then
useradd "$IIAB_ADMIN_USER"
echo "$IIAB_ADMIN_USER":"$IIAB_ADMIN_PUBLISHED_PWD" | chpasswd
fi
fi
# D. If 'iiab-admin' (or equivalent) use the default password, prompt for change
if check_user_pwd "$IIAB_ADMIN_USER" "$IIAB_ADMIN_PUBLISHED_PWD"; then
echo -e "\n\nUser '$IIAB_ADMIN_USER' retains default password '$IIAB_ADMIN_PUBLISHED_PWD' per http://FAQ.IIAB.IO\n"
echo -e "This is for login to Internet-in-a-Box's Admin Console (http://box.lan/admin)"
echo -e "Technical Details: https://github.com/iiab/iiab/blob/master/roles/iiab-admin\n"
echo -n "What password do you want for GNU/Linux user '$IIAB_ADMIN_USER' ? "
read ans < /dev/tty # Whines but doesn't change password if [Enter]
echo "$IIAB_ADMIN_USER":"$ans" | chpasswd || true # Overrides 'set -e'
fi
if [ -f $FLAGDIR/iiab-complete ]; then
echo -e "\n\nIIAB INSTALLATION (/usr/sbin/iiab) IS ALREADY COMPLETE -- per existence of:"
echo -e "$FLAGDIR/iiab-complete -- nothing to do.\n"
exit 0
fi
# E. Position & customize /etc/iiab/local_vars.yml
command -v wget &> /dev/null ||
$APTPATH/apt -y install wget # AS ABOVE (grep)
command -v nano &> /dev/null ||
$APTPATH/apt -y install nano # BELOW (git, jq)
local_vars_src_file=local_vars_big.yml # Testing default, for section I. (PR's can change local_vars.yml templates)
if [ -f /etc/iiab/local_vars.yml ]; then
# FUTURE: Test if their local_vars.yml is sufficiently version-compatible !
echo -e "\n\n EXISTING /etc/iiab/local_vars.yml is being used to install Internet-in-a-Box\n"
echo -e " 🚂 🚃 🚄 🚅 🚆 🚇 🚈 🚉 🚊 🚋 🚌 🚍 🚎 🚏 🚐 🚑 🚒 🚚 🚛 🚜 🚞 🚟 🚠 🚡 🚲\n"
echo -e " Google 'local_vars.yml' to learn more!"
else
echo -e "\n\nInstalling Internet-in-a-Box requires /etc/iiab/local_vars.yml\n"
echo -e "Do you want (1) 🚵 MIN-sized (2) 🚢🚣 MEDIUM-sized or (3) 🚂🚃🚃 BIG-sized?"
echo -e "Or (m) for 🚑 MEDICAL? YOU NEED 2 GB RAM OR HIGHER, IF YOU CHOOSE (3)\n"
echo -e 'See "What can I do with E-books and Internet-in-a-Box?" and "What services'
echo -e '(IIAB apps) are suggested during installation?" within http://FAQ.IIAB.IO\n'
echo -e "WARNING: This Can Take More Than An Hour, depending on Internet speed, CPU,"
echo -e "temperature, and the speed of your microSD card.\n"
echo -n "Please type 1, 2, 3 or m then press [ENTER]: "
read local_vars_size < /dev/tty
echo
case $local_vars_size in
1)
local_vars_src_file=local_vars_min.yml
;;
3)
local_vars_src_file=local_vars_big.yml
;;
m)
local_vars_src_file=local_vars_medical.yml
;;
*)
local_vars_src_file=local_vars_medium.yml
;;
esac
if [ -d /opt/iiab/iiab/vars ]; then
cp /opt/iiab/iiab/vars/$local_vars_src_file /etc/iiab/local_vars.yml
else
wget -O /etc/iiab/local_vars.yml https://github.com/iiab/iiab/raw/master/vars/$local_vars_src_file
fi
echo -en "\nEdit /etc/iiab/local_vars.yml to customize your Internet-in-a-Box? [Y/n] "
read ans < /dev/tty
if [ "$ans" != "n" ] && [ "$ans" != "N" ]; then
echo -e "\n1) PLEASE RUN: sudo nano /etc/iiab/local_vars.yml\n"
echo -e "2) After you're done editing, RUN 'sudo iiab' TO CONTINUE!\n"
exit 0
fi
fi
# F. Mandate OS SECURITY/UPDATES if 'apt update' has any (IF SO REBOOT)
# Educate implementer while waiting for 'apt update'
echo -e "\n\n ██████████████████████████████████████████████████████████████████████████████"
echo -e " ██ ██"
echo -e " ██ RUN 'sudo iiab' IF THIS INSTALL SCRIPT EVER FAILS, TO TRY TO CONTINUE! ██"
echo -e " ██ ██"
echo -e " ██████████████████████████████████████████████████████████████████████████████"
echo -e "\n\n'apt update' is checking for OS updates...\n"
#echo -e "2019-07-11 TEMP WORKAROUND FOR RASPBIAN BUSTER'S testing->stable apt GLITCH...\nDetails @ https://github.com/iiab/iiab/issues/1856\n"
#apt -y update || true # Overrides 'set -e'
#echo -e "\nNOW THE REAL 'apt update' WILL RUN...\n"
$APTPATH/apt -qq update > /tmp/apt.stdout 2> /tmp/apt.stderr || true # Overrides 'set -e'
if (( $(wc -c < /tmp/apt.stderr) > 82 )); then # apt.stderr typically contains exactly 82 characters when there are no errors, no matter the primary locale, i.e. 3-line file "\nWARNING: apt does not have a stable CLI interface. Use with caution in scripts.\n\n" ...OR... in other cases more than 82, e.g. many lines of errors when apt is busy/locked/offline/etc
echo -e "'apt update' FAILED. VERIFY YOU'RE ONLINE and resolve all errors below:\n"
cat /tmp/apt.stderr
exit 1
elif grep -q 'apt list --upgradable' /tmp/apt.stdout; then # apt.stdout typically contains {"All packages are up to date.\n" [even if primary locale is French & Hindi!], "Todos los paquetes están actualizados.\n", "所有软件包均为最新。\n"} ...OR... {"5 packages can be upgraded. Run 'apt list --upgradable' to see them.\n" [even if primary locale is French & Hindi!], "Se puede actualizar 1 paquete. Ejecute «apt list --upgradable» para verlo.\n", "有 1 个软件包可以升级。请执行 ‘apt list --upgradable’ 来查看它们。\n"}
cat /tmp/apt.stdout
echo -e "\nYour OS will now be upgraded...this takes time. THEN IT WILL AUTO-REBOOT.\n"
echo -n "Hit [ENTER] to confirm you'll RUN 'sudo iiab' AFTER IT REBOOTS: "
read ans < /dev/tty
echo
$APTPATH/apt -y dist-upgrade
reboot
exit 0 # Nec to avoid both output lines below (that confuse implementers!)
fi
cat /tmp/apt.stdout # "All packages are up to date.\n"
echo -ne "\nHit [ENTER] to confirm you'll TRY TO RERUN 'sudo iiab' IF THERE IS A PROBLEM: "
read ans < /dev/tty
####################### MAIN INTERACTIVE STUFF IS ABOVE #######################
# G. If microSD, lower reserve disk space from ~5% to 2%
#if [ -f /proc/device-tree/model ] && grep -qi raspberry /proc/device-tree/model; then
if [ -e /dev/mmcblk0p2 ]; then
echo -e "\n\nFound microSD card /dev/mmcblk0p2: Lower its reserve disk space from ~5% to 2%\n"
tune2fs -m 2 /dev/mmcblk0p2
fi
# H. Clone 3 IIAB repos
echo -e "\n\nDOWNLOAD (CLONE) IIAB'S 3 KEY REPOS INTO /opt/iiab ..."
command -v git &> /dev/null ||
$APTPATH/apt -y install git # AVOID UX CLUTTER+DELAYS
mkdir -p /opt/iiab
cd /opt/iiab
echo
if [ -d iiab ]; then
echo -e "REPO EXISTS? Consider 'cd /opt/iiab/iiab; git pull'"
else
git clone https://github.com/iiab/iiab
fi
echo
if [ -d iiab-admin-console ]; then
echo -e "REPO EXISTS? Consider 'cd /opt/iiab/iiab-admin-console; git pull'"
else
git clone https://github.com/iiab/iiab-admin-console
fi
echo
if [ -d iiab-factory ]; then
echo -e "REPO EXISTS? Consider 'cd /opt/iiab/iiab-factory; git pull'"
else
git clone https://github.com/iiab/iiab-factory
fi
# I. Install optional PR's
echo -e "\n\nINSTALL PR's FROM iiab/iiab OR iiab/iiab-admin-console -- USAGE EXAMPLES:\n"
echo -e " sudo iiab 361 2604 2607"
echo -e " curl d.iiab.io/install.txt | sudo bash -s 361 2604 2607\n"
command -v jq &> /dev/null ||
$APTPATH/apt -y install jq # sed better, to avoid delays?
if [ -s /etc/iiab/pr-queue ]; then # Set an email address for 'git pull' if one isn't yet set
git config --get user.email 1> /dev/null ||
git config --global user.email "[email protected]"
echo -e "\nYour git email is set to: $(git config --get user.email)"
echo -e 'Change this by running: sudo git config --global user.email "[email protected]"'
fi
cp /opt/iiab/iiab/vars/$local_vars_src_file /tmp
# Similar to 'for pr in "$@"' but survives reboots:
while [ -s /etc/iiab/pr-queue ] # Test that file exists and is non-empty
do
pr=$(head -1 /etc/iiab/pr-queue) # Try the next PR, from top of queue
if ! [[ "$pr" =~ ^[1-9][0-9]*$ ]]; then
echo -e "\n\e[1mInvalid PR number:\e[0m $pr\n"
echo -n "Delete it from top of /etc/iiab/pr-queue and continue? [Y/n] "
read ans < /dev/tty
[ "$ans" = "n" ] || [ "$and" = "N" ] &&
exit 1
sed -i '1d' /etc/iiab/pr-queue # Delete 1st line
continue
fi
if (( pr >= 1561 )); then # iiab/iiab's lowest PR as of October 2020
repo=iiab
else
repo=iiab-admin-console
fi
http_code=$(curl -sH "Accept: application/vnd.github.v3" https://api.github.com/repos/iiab/$repo/pulls/$pr -w "%{http_code}" -o /tmp/iiab-pr.json)
if [ "$http_code" != 200 ] ; then
echo -e "\n\e[41mCOULD NOT FIND PR #$pr (https://github.com/iiab/$repo/pull/$pr)\e[0m\n"
echo -en "\e[41mHTTP ERROR: $http_code\e[0m\e[1m "
[ "$http_code" = 403 ] &&
echo -en "(DID YOU REQUEST 60+ PR's IN ONE HOUR?)"
[ "$http_code" = 404 ] &&
echo -en "(IS #$pr AN ISSUE, RATHER THAN A PR?)"
echo -e "\n"
cat /tmp/iiab-pr.json # GitHub sometimes includes an English explanation of the error, and URL, e.g. https://developer.github.com/v3/#rate-limiting
echo
curl -IsH "Accept: application/vnd.github.v3" https://api.github.com/repos/iiab/$repo/pulls/$pr # HTTP headers typically reveal a lot more!
echo -n "Delete it from top of /etc/iiab/pr-queue and continue? [Y/n] "
read ans < /dev/tty
[ "$ans" = "n" ] || [ "$and" = "N" ] &&
exit 1
sed -i '1d' /etc/iiab/pr-queue # Delete 1st line
continue
fi
account=$(jq -r '.head.label' /tmp/iiab-pr.json | cut -d: -f1)
branch=$(jq -r '.head.label' /tmp/iiab-pr.json | cut -d: -f2)
echo -e "\nPR #$pr: cd /opt/iiab/$repo"
cd /opt/iiab/$repo
#git checkout -b POTLUCK master || true # If test branch name/norm in future...for both repos?
echo -e "git pull --no-edit https://github.com/$account/$repo $branch" # Or $repo.git
git pull --no-edit https://github.com/$account/$repo $branch || {
echo -e "\n\e[1mgit exit/error code:\e[0m $?\n" # if hides err code
echo -n "Delete it from top of /etc/iiab/pr-queue and continue? [Y/n] "
read ans < /dev/tty
[ "$ans" = "n" ] || [ "$and" = "N" ] &&
exit 1
sed -i '1d' /etc/iiab/pr-queue # Delete 1st line
continue
}
sed -i '1d' /etc/iiab/pr-queue # Delete 1st line
echo "$pr $(date '+%F %T %Z')" >> /etc/iiab/pr-list-pulled # For iiab-diagnostics
done
if ! cmp -s /tmp/$local_vars_src_file /opt/iiab/iiab/vars/$local_vars_src_file; then
mv /etc/iiab/local_vars.yml /etc/iiab/local_vars.yml.old
cp /opt/iiab/iiab/vars/$local_vars_src_file /etc/iiab/local_vars.yml
echo -e "\n\e[1mWARNING: /opt/iiab/iiab/vars/$local_vars_src_file HAS CHANGED!\n"
echo -e "YOUR /etc/iiab/local_vars.yml WAS MOVED TO /etc/iiab/local_vars.yml.old\e[0m\n"
echo -n "Edit the NEW /etc/iiab/local_vars.yml to customize Internet-in-a-Box? [Y/n] "
read ans < /dev/tty
if [ "$ans" != "n" ] && [ "$ans" != "N" ]; then
echo -e "\n1) PLEASE RUN: sudo nano /etc/iiab/local_vars.yml\n"
echo -e "2) After you're done editing, RUN 'sudo iiab' TO CONTINUE!\n"
exit 0
fi
fi
# J. Install Ansible + 2 IIAB repos
echo -e "\n\nINSTALL ANSIBLE + CORE IIAB SOFTWARE + ADMIN CONSOLE / CONTENT PACK MENUS...\n"
echo -e "Install Ansible..."
cd /opt/iiab/iiab/scripts/
./ansible
echo -e "\n┌──────────────────────────────────────────────────────────────────────────────┐"
echo -e "│ │"
echo -e "│ NOW INSTALL IIAB SOFTWARE! If glitches arise (connectivity or otherwise) │"
echo -e "│ │"
echo -e "│ PLEASE TRY TO CONTINUE BY RE-RUNNING PARENT SCRIPT 'sudo iiab' -- or run │"
echo -e "│ │"
echo -e "│ child script ./iiab-install -- both avoid repeating any of the 9 stages. │"
echo -e "│ │"
echo -e "└──────────────────────────────────────────────────────────────────────────────┘"
cd /opt/iiab/iiab/
./iiab-install # "$@"
if [ -f $FLAGDIR/iiab-admin-console-complete ]; then
echo -e "ADMIN CONSOLE INSTALLATION IS ALREADY COMPLETE -- per existence of:"
echo -e "$FLAGDIR/iiab-admin-console-complete\n"
elif grep -q '^admin_console_install:\s\+[fF]alse\b' /etc/iiab/local_vars.yml ; then
echo -e "LET'S NOT TRY TO INSTALL ADMIN CONSOLE -- because:"
echo -e "'admin_console_install: False' is in /etc/iiab/local_vars.yml\n"
else
echo -e "Install Admin Console... (also runs iiab-get-kiwix-cat to d/l Kiwix catalog,"
echo -e "and installs Dynamic Menuing for /library/www/html/home/index.html)\n"
cd /opt/iiab/iiab-admin-console
./install
touch $FLAGDIR/iiab-admin-console-complete
fi
if grep -q '^admin_console_enabled:\s\+[fF]alse\b' /etc/iiab/local_vars.yml ; then
echo -e "'admin_console_enabled: False' is in /etc/iiab/local_vars.yml"
echo -e "...so let's try to DISABLE & STOP Admin Console's iiab-cmdsrv.service\n"
systemctl disable iiab-cmdsrv || true # Overrides 'set -e'
systemctl stop iiab-cmdsrv || true # Overrides 'set -e'
else
echo -e "'admin_console_enabled: False' isn't in /etc/iiab/local_vars.yml"
echo -e "...so let's try to ENABLE & START Admin Console's iiab-cmdsrv.service\n"
systemctl enable iiab-cmdsrv || true # Overrides 'set -e'
systemctl start iiab-cmdsrv || true # Overrides 'set -e'
fi
# K. KA Lite prep
if [ -d /library/ka-lite ]; then
echo -e "\n\nKA LITE REQUIRES 2 THINGS...\n"
echo -e "Register with KA Lite - just the anonymous registration...\n"
# /usr/bin/kalite venv wrapper invokes 'export KALITE_HOME=/library/ka-lite'
if [ ! -f $FLAGDIR/kalite-zone-complete ]; then
echo -e "Now running 'kalite manage generate_zone' ...\n"
kalite manage generate_zone || true # Overrides 'set -e'
touch $FLAGDIR/kalite-zone-complete
else
echo -e "'kalite manage generate_zone' IS ALREADY COMPLETE -- per existence of:"
echo -e "$FLAGDIR/kalite-zone-complete\n"
fi
echo -e "\nInstall KA Lite's mandatory 0.9 GB English Pack... (en.zip)\n"
if [ ! -f $FLAGDIR/kalite-en.zip-complete ]; then
#echo -e 'Now retrieving it...\n'
cd /tmp
if [ -f en.zip ]; then
if [ $(wc -c < en.zip) -ne 929916955 ]; then
echo -e "\nERROR: /tmp/en.zip must be 929,916,955 bytes to proceed.\n" >&2
exit 1
else
echo -e "\nUsing existing /tmp/en.zip whose 929,916,955 byte size is correct!\n"
fi
else
wget http://pantry.learningequality.org/downloads/ka-lite/0.17/content/contentpacks/en.zip
fi
echo -e 'Now installing /tmp/en.zip into /library/ka-lite/content/*\n'
kalite manage retrievecontentpack local en en.zip
touch $FLAGDIR/kalite-en.zip-complete
fi
fi
# WARNING: /tmp/en.zip (and all stuff in /tmp) is auto-deleted during reboots
# NEW WAY ABOVE - since 2018-07-03 - installs KA Lite's mandatory English Pack
#
# kalite manage retrievecontentpack download en
# OLD WAY ABOVE - fails w/ sev ISPs per https://github.com/iiab/iiab/issues/871
# L. Start BitTorrent downloads, e.g. if /etc/iiab/local_vars.yml requested any
if systemctl -q is-active transmission-daemon; then
echo -e "\n\nSTARTING BITTORRENT DOWNLOAD(S) for KA Lite...Please Monitor: http://box:9091\n"
transmission-remote -n Admin:changeme -t all --start
fi
touch $FLAGDIR/iiab-complete
# M. Educate Implementers prior to rebooting!
echo -e "\n\n ┌───────────────────────────────────────────────────────────┐"
echo -e " │ │"
echo -e " │ INTERNET-IN-A-BOX (IIAB) SOFTWARE INSTALL IS COMPLETE │"
echo -e " │ │"
echo -e " └───────────────────────────────────────────────────────────┘\n"
echo -e "(1A) A couple minutes after you reboot (below) try to connect any laptop to"
echo -e 'Wi-Fi hotspot "Internet in a Box". If this works, verify that you can browse'
echo -e "to http://box or http://box.lan or http://172.18.96.1\n"
echo -e "(1B) IF THOSE 3 DON'T WORK, try http://box.local from any device connected to"
echo -e "your usual network. Or try http://localhost from your IIAB itself!\n"
echo -e "(1C) IF ALL 5 ABOVE DON'T WORK, ask the person who set up the network/router"
echo -e "in your building for the IP address of your IIAB, so you can browse to it"
echo -e "using (something like) http://192.168.0.100\n"
echo -e '(2) ADD CONTENT using http://box.lan/admin (changing "box.lan" to be as above!)'
echo -e 'PLEASE READ "What are the default passwords?" and "How do I customize my'
echo -e 'Internet-in-a-Box home page?" at http://FAQ.IIAB.IO\n'
echo -e "(3) Please run the 'iiab-diagnostics' command, to generate a URL summarizing"
echo -e "your IIAB configuration, for volunteers seeking to help you. We strongly"
echo -e "encourage you to share this URL also when connecting with others in the IIAB"
echo -e "global community, learning from other initiatives in your region and beyond!\n"
#echo -e "(3) If you're installing IIAB over Wi-Fi (instead of Ethernet) remember to run"
#echo -e "'iiab-hotspot-on' at the VERY END, when you're ready to ACTIVATE YOUR IIAB's"
#echo -e "INTERNAL WI-FI HOTSPOT. CAUTION: this permanently kills your IIAB's Internet"
#echo -e "(over Wi-Fi anyway) until you later run 'iiab-hotspot-off'. CAVEAT: these"
#echo -e "two commands only work with Raspberry Pi as of 2019-09-30.\n"
echo -ne "HIT [Enter] TO REBOOT, CONFIRMING YOU'VE" '"photographed" THE ABOVE PARAGRAPHS: '
read ans < /dev/tty
# Sets hostname, improves RTC + memory mgmt, starts BitTorrents if needed, etc!
reboot