-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpostUpdate.sh
executable file
·72 lines (59 loc) · 2.04 KB
/
postUpdate.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
#!/bin/bash
./copyDefaultFiles.py
# Check if swap space is being used
if [ -f /my_swap ]; then
if grep --quiet /my_swap /etc/fstab; then
echo "Swap space already being allocated at boot"
else
sudo mkswap /my_swap
sudo swapon /my_swap
sudo su -c 'echo "/my_swap swap swap defaults 0 0" >> /etc/fstab'
fi
fi
./ensureTmpRemotesAdded.sh
./ensurePublicKeysAdded.sh
# Check for internet connection.
if ping -q -c 1 -W 1 github.com >/dev/null; then
# Update /opt/scripts/boot to commit b61125c1485bee929340cacc06c85c6fcfd678bc
# This commit changes the ethernet-over-usb protocol used with macOS from ECM
# to NCM, because with v11 macOS no longer supports ECM
cd /opt/scripts/boot
sudo git fetch origin
sudo git checkout b61125c1485bee929340cacc06c85c6fcfd678bc
if ! dpkg -l | grep bb-usb-gadgets; then
sudo apt update
sudo apt install bb-usb-gadgets
fi
else #If no connection, assume update is occuring over USB
if [ -d /tmp/boot-scripts/ ]; then
cd /opt/scripts/boot
git remote add tmp /tmp/boot-scripts
sudo git fetch tmp
sudo git checkout b61125c1485bee929340cacc06c85c6fcfd678bc
fi
if [ -d /tmp/ ] && ! dpkg -l | grep bb-usb-gadgets; then
sudo dpkg -i /tmp/debs/bb-usb-gadgets_1.20200504.0-0~stretch+20200504_all.deb
fi
fi
# Prevent shared memory from being cleaned up when pocketnc user closes SSH
sudo sed -i 's/^#RemoveIPC=yes/RemoveIPC=no/' /etc/systemd/logind.conf
# Remove line which is incorrectly setting usb0 as default gateway from /etc/network/interfaces
# ONLY IF bb-usb-gadgets IS INSTALLED.
# We would rather have:
# - usb tethering working, network gateway broken
# than
# - network gateway working, usb tethering broken
if dpkg-query -s bb-usb-gadgets | grep "install ok installed"; then
sudo sed -i 's/^\([^#]*gateway\)/#\1/g' /etc/network/interfaces
else
sudo sed -i '/gateway/s/#//g' /etc/network/interfaces
fi
cd /home/pocketnc/pocketnc/Settings
if [ -x ./dtc.sh ]; then
sudo ./dtc.sh
fi
if [ -x ./postUpdate ]; then
./postUpdate
fi
cd ..
sudo systemctl --system daemon-reload