-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathstart_chroot_script
executable file
·74 lines (56 loc) · 1.91 KB
/
start_chroot_script
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
#!/usr/bin/env bash
set -x
set -e
# CustomPiOS auto-hotspot module
# Script sets up an automatic hotspot if no wifi is found
# Based on http://www.raspberryconnect.com/network/item/330-raspberry-pi-auto-wifi-hotspot-switch-internet
# Written by Guy Sheffer <guysoft at gmail dot com>
# GPL V3
########
source /common.sh
apt-get update --allow-releaseinfo-change
apt-get -y purge dns-root-data
apt-get -y install iw
apt-get purge dns-root-data
apt-get install -y hostapd dnsmasq iptables
systemctl disable hostapd
systemctl disable dnsmasq
# Unpack after hostapd dnsmasq so we can overwrite their config if needed
unpack /filesystem/root /
# Set hotspot name and password
sed -i s"/AUTO_HOTSPOT_NAME/$AUTO_HOTSPOT_NAME/g" /etc/hostapd/hostapd.conf
sed -i s"/AUTO_HOTSPOT_PASSWORD/$AUTO_HOTSPOT_PASSWORD/g" /etc/hostapd/hostapd.conf
sed -i s"/AUTO_HOTSPOT_CHANNEL/$AUTO_HOTSPOT_CHANNEL/g" /etc/hostapd/hostapd.conf
if grep -Fxq "DAEMON_CONF" /etc/default/hostapd
then
sed -i "s@#DAEMON_CONF=\"\"@DAEMON_CONF=\"/etc/hostapd/hostapd.conf\"@g" /etc/default/hostapd
else
echo DAEMON_CONF=\"/etc/hostapd/hostapd.conf\" >> /etc/default/hostapd
fi
sed -i "s@^DAEMON_OPTS=\"\"@^#DAEMON_OPTS=\"\"@g" /etc/default/hostapd
echo "
# IPv6
duid
interface eth0
ipv6rs
iaid 1
ia_pd 2 wlan0/1/64 # request prefixes for VLANs
" >> /etc/dhcpcd.conf
sed -i 's/clientid/# clientid/g' /etc/dhcpcd.conf
echo "
# Auto-hotspot Config
# Interface to use
interface=wlan0
bind-interfaces
dhcp-range=192.168.50.150,192.168.50.200,255.255.255.0,12h
# IPv6
except-interface=eth0
enable-ra
dhcp-range=tag:wlan0,::1,constructor:wlan0, ra-names, 12h
" >> /etc/dnsmasq.conf
sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
cp /etc/network/interfaces /etc/network/interfaces-backup
echo "" > /etc/network/interfaces
# Add cronjob
echo "* * * * * /usr/bin/autohotspotN" | crontab -
systemctl enable autohotspot.service