forked from RoboCup-SSL/ssl-remote-control
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·88 lines (74 loc) · 2.93 KB
/
bootstrap.sh
File metadata and controls
executable file
·88 lines (74 loc) · 2.93 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
#!/usr/bin/env bash
set -Eeuo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
CONFIG_DIR="$HOME/.config/ssl-remote-control"
CONFIG_ENV_FILE="$CONFIG_DIR/remote-control-config.env"
SRC_VERSION=${1:-}
function updateSystem() {
sudo apt-get update
sudo apt-get -y dist-upgrade
sudo apt-get -y install vim
}
function installService() {
mkdir -p ~/.local/share/systemd/user/
cp "$SCRIPT_DIR/ssl-remote-control.service" ~/.local/share/systemd/user/ssl-remote-control.service
systemctl --user enable ssl-remote-control.service
if [[ ! -f "${CONFIG_ENV_FILE}" ]]; then
mkdir -p "${CONFIG_DIR}"
echo "Copying remote control configuration file to ${CONFIG_ENV_FILE}"
cp "${SCRIPT_DIR}/remote-control-config.env" "${CONFIG_ENV_FILE}"
else
echo "Found remote control configuration file at ${CONFIG_ENV_FILE} skipping"
fi
}
function installRemoteControl() {
sudo apt-get install --no-install-recommends -y curl jq
systemctl --user stop ssl-remote-control.service
mkdir -p ~/.local/bin/
if [[ -z "${SRC_VERSION}" ]]; then
SRC_VERSION="$(curl -s https://api.github.com/repos/RoboCup-SSL/ssl-remote-control/releases/latest | jq -r '.tag_name')"
fi
echo "Installing version: ${SRC_VERSION}"
wget "https://github.com/RoboCup-SSL/ssl-remote-control/releases/download/${SRC_VERSION}/ssl-remote-control_${SRC_VERSION}_linux_arm" -O ~/.local/bin/ssl-remote-control
chmod +x ~/.local/bin/ssl-remote-control
systemctl --user start ssl-remote-control.service
}
function installBrowser() {
# https://blog.r0b.io/post/minimal-rpi-kiosk/
sudo apt-get install --no-install-recommends -y \
xserver-xorg-video-all xserver-xorg-input-all xserver-xorg-core xinit x11-xserver-utils \
unclutter \
xinput \
chromium-browser
# Enable Auto-Login on console
mkdir -p /etc/systemd/system/getty@tty1.service.d
sudo cp "${SCRIPT_DIR}/autologin.conf" /etc/systemd/system/getty@tty1.service.d/autologin.conf
# Configure to run browser when X starts
cp "${SCRIPT_DIR}/.xinitrc" ~/.xinitrc
# Configure to run X on tty1
cp "${SCRIPT_DIR}/.bash_profile" ~/.bash_profile
}
function install_nwjs() {
sudo apt install apt-transport-https
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys DB348A58A292E9BC
echo "deb https://repo.netsyms.com/apt main main" | sudo tee /etc/apt/sources.list.d/netsyms.list
sudo apt update
sudo apt install nw.js-normal
mkdir -p ~/nwjs
cp "${SCRIPT_DIR}/package.json" ~/nwjs
}
function configurePi() {
sudo cp "${SCRIPT_DIR}/config.txt" /boot/config.txt
cp "${SCRIPT_DIR}/update.sh" ~/update.sh
}
updateSystem
installService
installRemoteControl
installBrowser
install_nwjs
configurePi
echo "You may need to restart the system to apply some settings. Reboot now? (y/n)"
read -r response
if [[ "${response}" == "y" ]]; then
sudo reboot
fi