-
Notifications
You must be signed in to change notification settings - Fork 0
/
prereq.sh
executable file
·154 lines (116 loc) · 4.38 KB
/
prereq.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
#!/bin/bash
set -e
if [ -z $1 ] ; then
echo "Usage: $0 <ssh_host>"
exit 1
fi
if [ "z$UID" != "z0" ] ; then
echo "Copying script to box..."
scp $0 `basedir $0`/oled.diff root@$1:/tmp/prereq.sh
ssh root@$1 'chmod +x /tmp/prereq.sh'
echo "Running package install..."
ssh root@$1 '/tmp/prereq.sh install'
echo "Running Deploy..."
./deploy.sh $1
echo "Enabling services..."
ssh root@$1 '/tmp/prereq.sh services'
echo "Rebooting..."
ssh root@$1 '/tmp/prereq.sh reboot'
exit 0
fi
echo "Script running on box :: Phase $1 ..."
# Ubuntu:
# PKGS="joe lighttpd php-cli php-cgi ifplugd dkms git"
# Raspbian:
# PKGS="joe lighttpd firmware-realtek dkms git raspberrypi-kernel-headers php-file php-file-iterator php-http-upload php5 php5-cgi php5-cli php5-curl php5-fpm php5-json php5-memcached lighttpd hostapd forked-daapd dnsmasq minidlna wpasupplicant memcached php-compat php5-mcrypt i2c-tools"
# CHIP:
# PKGS="joe lighttpd firmware-realtek dkms git php-file php-file-iterator php5 php5-cgi php5-cli php5-curl php5-fpm php5-json php5-memcached lighttpd hostapd forked-daapd dnsmasq minidlna wpasupplicant memcached php5-mcrypt i2c-tools"
# Armbian Banana-Pi
PKGS="joe ntpdate php5-dev ifplugd python-pip libfreetype6-dev libjpeg-dev python-setuptools python-dev libpython-dev attr acpid watchdog lighttpd dkms git php-file php-file-iterator php5 php5-cgi php5-cli php5-curl php5-fpm php5-json php5-memcached lighttpd hostapd forked-daapd dnsmasq minidlna wpasupplicant memcached php5-mcrypt i2c-tools"
if [ "z$1" == "zinstall" ] ; then
echo "Installing packages..."
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
dist-upgrade
DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
install $PKGS
DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
remove fake-hwclock
DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
purge fake-hwclock
DEBIAN_FRONTEND=noninteractive apt-get --force-yes -y \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
autoremove
pecl install xattr
echo "Cleaning up permissions..."
chsh -s /bin/bash www-data
WWWHOME=`grep www-data /etc/passwd | cut -d: -f6`
mkdir -p $WWWHOME/.ssh
cp /root/.ssh/authorized_keys $WWWHOME/.ssh
chown -R www-data $WWWHOME
chmod 700 $WWWHOME/.ssh
chmod 600 $WWWHOME/.ssh/authorized_keys
echo "Building 8812au module..."
cd /usr/src
if [ ! -d rtl8812AU_8821AU_linux-1.0 ] ; then
git clone https://github.com/abperiasamy/rtl8812AU_8821AU_linux rtl8812AU_8821AU_linux-1.0
else
cd rtl8812AU_8821AU_linux-1.0
git pull
cd ..
fi
sed -i -e 's/CONFIG_POWER_SAVING = y/CONFIG_POWER_SAVING = n/' rtl8812AU_8821AU_linux-1.0/Makefile
sed -i -e 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/' rtl8812AU_8821AU_linux-1.0/Makefile
sed -i -e 's/CONFIG_PLATFORM_ARM_RPI = n/CONFIG_PLATFORM_ARM_RPI = y/' rtl8812AU_8821AU_linux-1.0/Makefile
if ! `dkms status | grep -q rtl8812AU_8821AU_linux` ; then
dkms add -m rtl8812AU_8821AU_linux -v 1.0
fi
dkms build -m rtl8812AU_8821AU_linux -v 1.0
dkms install -m rtl8812AU_8821AU_linux -v 1.0
if ! `grep 8812au /etc/modules` ; then
echo "88128au" >> /etc/modules
fi
pip install image
pip install psutil
pip install Twisted
cd /usr/src
git clone https://github.com/hallard/ArduiPi_OLED.git
cd ArduiPi_OLED
patch -p1 < /tmp/oled.diff
echo 2 | ./autogen.sh
make
cd /usr/src
git clone https://github.com/rm-hull/ssd1306
elif [ "z$1" == "zservices" ] ; then
echo "Activating services..."
SVCS="minidlna lighttpd dnsmasq hostapd memcached forked-daapd acpid setup-data axp20x logo update-screen power-notify ifplugd rtc-i2c"
for f in $SVSC ; do
echo "Enabling ${f}..."
systemctl enable $f
done
OLD_SVCS="watchdog"
for f in $OLD_SVCS ; do
echo "Enabling ${f}..."
update-rc.d $f defaults
done
# Don't want lirc...
systemctl disable lircd || true
apt-get remove lirc || true
elif [ "z$1" == "zreboot" ] ; then
echo "Rebooting box..."
rm -f $0
reboot
else
echo "Unknown phase."
exit 1
fi