-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgenapkovl-penyuxen.sh
202 lines (154 loc) · 4.14 KB
/
genapkovl-penyuxen.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
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
#!/bin/sh -e
HOSTNAME="penyu"
if [ -z "$HOSTNAME" ]; then
echo "usage: $0 hostname"
exit 1
fi
cleanup() {
rm -rf "$tmp"
}
makefile() {
OWNER="$1"
PERMS="$2"
FILENAME="$3"
cat > "$FILENAME"
chown "$OWNER" "$FILENAME"
chmod "$PERMS" "$FILENAME"
}
rc_add() {
mkdir -p "$tmp"/etc/runlevels/"$2"
ln -sf /etc/init.d/"$1" "$tmp"/etc/runlevels/"$2"/"$1"
}
tmp="$(mktemp -d)"
trap cleanup EXIT
mkdir -p "$tmp"/etc
makefile root:root 0644 "$tmp"/etc/hostname <<EOF
$HOSTNAME
EOF
mkdir -p "$tmp"/etc/network
makefile root:root 0644 "$tmp"/etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOF
makefile root:root 0644 "$tmp"/etc/modules <<EOF
xen_netback
xen_blkback
xenfs
xen-platform-pci
xen_wdt
tun
EOF
mkdir -p "$tmp"/etc/apk
makefile root:root 0644 "$tmp"/etc/apk/world <<EOF
alpine-base
docker
dnsmasq
hostapd
network-extras
git
xen
EOF
makefile root:root 0644 "$tmp"/etc/issue <<EOF
Welcome to PenyuOS
Kernel \r on an \m (\l)
EOF
makefile root:root 0644 "$tmp"/etc/motd <<EOF
=> PenyuOS Powered by Aksaramaya <http://aksaramaya.com>
__
_____ | | __ ___________ ____________ _____ _____ ___.__._____
\__ \ | |/ / / ___/\__ \\_ __ \__ \ / \\__ \< | |\__ \
/ __ \| < \___ \ / __ \| | \// __ \| Y Y \/ __ \\___ | / __ \_
(____ /__|_ \/____ >(____ /__| (____ /__|_| (____ / ____|(____ /
\/ \/ \/ \/ \/ \/ \/\/ \/
=> Bugs : https://github.com/orcinustools/penyu/issues
=> Install : 'sh /etc/installer-script/penyu-default-install'
EOF
mkdir -p "$tmp"/etc/installer-script
makefile root:root 0755 "$tmp"/etc/installer-script/penyu-wifi <<'WIFI'
#!/bin/sh
ifconfig wlan0 up
cat > /etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
EOF
echo "===> scanning wifi......."
iwlist wlan0 scan | grep 'ESSID\|Encryption'
echo -n "===> Select ESSID : "
read ESSID
iwconfig wlan0 essid $ESSID
echo "===> wifi password : "
wpa_passphrase $ESSID > /etc/wpa_supplicant/wpa_supplicant.conf
wpa_supplicant -B -Dwext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
service networking restart
ifconfig wlan0
WIFI
makefile root:root 0755 "$tmp"/etc/installer-script/penyu-default-install <<'EOF'
#!/bin/sh
cat > /tmp/welcome.txt <<'_EOF_'
=> PenyuOS installer.....
__
_____ | | __ ___________ ____________ _____ _____ ___.__._____
\__ \ | |/ / / ___/\__ \\_ __ \__ \ / \\__ \< | |\__ \
/ __ \| < \___ \ / __ \| | \// __ \| Y Y \/ __ \\___ | / __ \_
(____ /__|_ \/____ >(____ /__| (____ /__|_| (____ / ____|(____ /
\/ \/ \/ \/ \/ \/ \/\/ \/
=> Bugs : https://github.com/orcinustools/penyu/issues
_EOF_
cat > /tmp/installer.conf <<'_EOF_'
# Example answer file for setup-penyu script
# If you don't want to use a certain option, then comment it out
# Use US layout with US variant
KEYMAPOPTS="us us"
# Set hostname to penyu-test
HOSTNAMEOPTS="-n penyu"
# Contents of /etc/network/interfaces
INTERFACESOPTS="auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
hostname penyu
"
# Search domain of example.com, Google public nameserver
DNSOPTS=""
# Set timezone to UTC
TIMEZONEOPTS="-z UTC"
# set http/ftp proxy
PROXYOPTS="none"
APKREPOSOPTS="-r"
# Install Openssh
SSHDOPTS="-c openssh"
# Use openntpd
NTPOPTS="-c chrony"
# Use /dev/sda as a data disk
DISKOPTS="-m sys /dev/sda"
_EOF_
cat /tmp/welcome.txt
/sbin/setup-alpine -f /tmp/installer.conf
EOF
rc_add devfs sysinit
rc_add dmesg sysinit
rc_add mdev sysinit
rc_add hwdrivers sysinit
rc_add modloop sysinit
# xen server additional
rc_add udev-postmount default
rc_add xenstored default
rc_add xenconsoled default
rc_add hwclock boot
rc_add modules boot
rc_add sysctl boot
rc_add hostname boot
rc_add bootmisc boot
rc_add syslog boot
rc_add docker boot
rc_add udhcpd boot
rc_add mount-ro shutdown
rc_add killprocs shutdown
rc_add savecache shutdown
tar -c -C "$tmp" etc | gzip -9n > $HOSTNAME.apkovl.tar.gz