-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·59 lines (46 loc) · 1.36 KB
/
setup.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
#!/usr/bin/env bash
# app skeleton for raspberry pi
# usage:
# wget https://raw.githubusercontent.com/avishayp/pi-app/master/setup.sh
# chmod +x setup.sh
# ./setup.sh ssid_name ssid_pass
#
# default values are all raspberry-app (security at user's risk)
# run from reporoot/
pushd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
get_source() {
which git || sudo apt-get install -y git
SOURCEDIR="$(mktemp -d)"
git clone https://github.com/avishayp/pi-app ${SOURCEDIR}
cp -R ${SOURCEDIR}/fakeroot ./
cp -R ${SOURCEDIR}/server ./
rm -fR ${SOURCEDIR}
}
first_time_setup() {
sudo apt-get update
sudo apt-get install -y \
dnsmasq \
hostapd \
logrotate \
nginx \
python3 \
python3-pip \
rsyslog \
supervisor
if [ ! -d server ] ; then
echo "get files first"
get_source
fi
sudo pip3 install -r server/requirements.txt
}
update() {
echo "updating ap params"
sed -i "s/ssid=.*/ssid=${SSID_NAME}/g; s/wpa_passphrase=.*/wpa_passphrase=${SSID_PASS}/g" fakeroot/etc/hostapd/hostapd.conf
sudo cp -pRv fakeroot/* /
sudo cp -pRv server /srv/
echo "restarting..."
which reboot && sudo reboot || echo "no reboot - likely docker container. move on"
}
SSID_NAME=${1-"raspberry-app"}
SSID_PASS=${2-"raspberry-app"}
first_time_setup && update