Can use wifi networks config file from the image builder
This commit is contained in:
parent
494af60013
commit
2b14e18748
|
@ -106,6 +106,7 @@ WIFI_SSID=
|
||||||
WIFI_TYPE='wpa-psk'
|
WIFI_TYPE='wpa-psk'
|
||||||
WIFI_PASSPHRASE=
|
WIFI_PASSPHRASE=
|
||||||
WIFI_HOTSPOT='no'
|
WIFI_HOTSPOT='no'
|
||||||
|
WIFI_NETWORKS_FILE=${PROJECT_NAME}-wifi.cfg
|
||||||
|
|
||||||
mesh_router_setup_script() {
|
mesh_router_setup_script() {
|
||||||
# create a setup script for a mesh router
|
# create a setup script for a mesh router
|
||||||
|
@ -249,6 +250,10 @@ do
|
||||||
WIFI_HOTSPOT='yes'
|
WIFI_HOTSPOT='yes'
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
--wifinetworks)
|
||||||
|
shift
|
||||||
|
WIFI_NETWORKS_FILE="$1"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# unknown option
|
# unknown option
|
||||||
;;
|
;;
|
||||||
|
@ -356,7 +361,8 @@ make $IMAGE_TYPE \
|
||||||
WIFI_SSID="$WIFI_SSID" \
|
WIFI_SSID="$WIFI_SSID" \
|
||||||
WIFI_TYPE="$WIFI_TYPE" \
|
WIFI_TYPE="$WIFI_TYPE" \
|
||||||
WIFI_PASSPHRASE="$WIFI_PASSPHRASE" \
|
WIFI_PASSPHRASE="$WIFI_PASSPHRASE" \
|
||||||
WIFI_HOTSPOT="$WIFI_HOTSPOT"
|
WIFI_HOTSPOT="$WIFI_HOTSPOT" \
|
||||||
|
WIFI_NETWORKS_FILE="$WIFI_NETWORKS_FILE"
|
||||||
|
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
echo $'Build failed'
|
echo $'Build failed'
|
||||||
|
|
|
@ -84,57 +84,58 @@ WIFI_SSID=
|
||||||
WIFI_TYPE='wpa-psk'
|
WIFI_TYPE='wpa-psk'
|
||||||
WIFI_PASSPHRASE=
|
WIFI_PASSPHRASE=
|
||||||
WIFI_HOTSPOT='no'
|
WIFI_HOTSPOT='no'
|
||||||
|
WIFI_NETWORKS_FILE=${PROJECT_NAME}-wifi.cfg
|
||||||
|
|
||||||
enable_eatmydata_override() {
|
enable_eatmydata_override() {
|
||||||
chroot $rootdir apt-get install --no-install-recommends -y eatmydata
|
chroot $rootdir apt-get install --no-install-recommends -y eatmydata
|
||||||
if [ -x $rootdir/usr/bin/eatmydata ] && \
|
if [ -x $rootdir/usr/bin/eatmydata ] && \
|
||||||
[ ! -f $rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata ]; then
|
[ ! -f $rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata ]; then
|
||||||
echo $"info: Adding apt config to call dpkg via eatmydata"
|
echo $"info: Adding apt config to call dpkg via eatmydata"
|
||||||
printf "#!/bin/sh\nexec eatmydata dpkg \"\$@\"\n" \
|
printf "#!/bin/sh\nexec eatmydata dpkg \"\$@\"\n" \
|
||||||
> $rootdir/var/tmp/dpkg-eatmydata
|
> $rootdir/var/tmp/dpkg-eatmydata
|
||||||
chmod 755 $rootdir/var/tmp/dpkg-eatmydata
|
chmod 755 $rootdir/var/tmp/dpkg-eatmydata
|
||||||
cat > $rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata <<EOF
|
cat > $rootdir/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata <<EOF
|
||||||
Dir::Bin::dpkg "/var/tmp/dpkg-eatmydata";
|
Dir::Bin::dpkg "/var/tmp/dpkg-eatmydata";
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
echo $"error: unable to find /usr/bin/eatmydata after installing the eatmydata package"
|
echo $"error: unable to find /usr/bin/eatmydata after installing the eatmydata package"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
disable_eatmydata_override() {
|
disable_eatmydata_override() {
|
||||||
for override in \
|
for override in \
|
||||||
/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata \
|
/etc/apt/apt.conf.d/95debian-edu-install-dpkg-eatmydata \
|
||||||
/var/tmp/dpkg-eatmydata ; do
|
/var/tmp/dpkg-eatmydata ; do
|
||||||
echo $"info: Removing apt config to call dpkg via eatmydata"
|
echo $"info: Removing apt config to call dpkg via eatmydata"
|
||||||
if [ -f $rootdir$override ] ; then
|
if [ -f $rootdir$override ] ; then
|
||||||
rm -f $rootdir$override
|
rm -f $rootdir$override
|
||||||
else
|
else
|
||||||
echo $"warning: missing $rootdir$override"
|
echo $"warning: missing $rootdir$override"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
sync # Flush file buffers before continuing
|
sync # Flush file buffers before continuing
|
||||||
}
|
}
|
||||||
|
|
||||||
set_apt_sources() {
|
set_apt_sources() {
|
||||||
NEW_MIRROR="$1"
|
NEW_MIRROR="$1"
|
||||||
COMPONENTS="main"
|
COMPONENTS="main"
|
||||||
|
|
||||||
cat <<EOF > etc/apt/sources.list
|
cat <<EOF > etc/apt/sources.list
|
||||||
deb $NEW_MIRROR $SUITE $COMPONENTS
|
deb $NEW_MIRROR $SUITE $COMPONENTS
|
||||||
deb-src $NEW_MIRROR $SUITE $COMPONENTS
|
deb-src $NEW_MIRROR $SUITE $COMPONENTS
|
||||||
|
|
||||||
#deb http://security.debian.org/ $SUITE/updates main
|
#deb http://security.debian.org/ $SUITE/updates main
|
||||||
#deb-src http://security.debian.org/ $SUITE/updates main
|
#deb-src http://security.debian.org/ $SUITE/updates main
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_networking() {
|
configure_networking() {
|
||||||
if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
|
if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $GENERIC_IMAGE == "no" ]]; then
|
if [[ $GENERIC_IMAGE == "no" ]]; then
|
||||||
echo "# This file describes the network interfaces available on your system
|
echo "# This file describes the network interfaces available on your system
|
||||||
# and how to activate them. For more information, see interfaces(5).
|
# and how to activate them. For more information, see interfaces(5).
|
||||||
|
|
||||||
# The loopback network interface
|
# The loopback network interface
|
||||||
|
@ -148,43 +149,43 @@ iface eth0 inet static
|
||||||
netmask 255.255.255.0
|
netmask 255.255.255.0
|
||||||
gateway $ROUTER_IP_ADDRESS
|
gateway $ROUTER_IP_ADDRESS
|
||||||
dns-nameservers $NAMESERVER1 $NAMESERVER2
|
dns-nameservers $NAMESERVER1 $NAMESERVER2
|
||||||
# Example to keep MAC address between reboots
|
# Example to keep MAC address between reboots
|
||||||
#hwaddress ether B5:A2:BE:3F:1A:FE
|
#hwaddress ether B5:A2:BE:3F:1A:FE
|
||||||
|
|
||||||
# The secondary network interface
|
# The secondary network interface
|
||||||
#auto eth1
|
#auto eth1
|
||||||
#iface eth1 inet dhcp
|
#iface eth1 inet dhcp
|
||||||
|
|
||||||
# WiFi Example
|
# WiFi Example
|
||||||
#auto wlan0
|
#auto wlan0
|
||||||
#iface wlan0 inet dhcp
|
#iface wlan0 inet dhcp
|
||||||
# wpa-ssid \"essid\"
|
# wpa-ssid \"essid\"
|
||||||
# wpa-psk \"password\"
|
# wpa-psk \"password\"
|
||||||
|
|
||||||
# Ethernet/RNDIS gadget (g_ether)
|
# Ethernet/RNDIS gadget (g_ether)
|
||||||
# ... or on host side, usbnet and random hwaddr
|
# ... or on host side, usbnet and random hwaddr
|
||||||
# Note on some boards, usb0 is automaticly setup with an init script
|
# Note on some boards, usb0 is automaticly setup with an init script
|
||||||
#iface usb0 inet static
|
#iface usb0 inet static
|
||||||
# address 192.168.7.2
|
# address 192.168.7.2
|
||||||
# netmask 255.255.255.0
|
# netmask 255.255.255.0
|
||||||
# network 192.168.7.0
|
# network 192.168.7.0
|
||||||
# gateway 192.168.7.1" > $rootdir/etc/network/interfaces
|
# gateway 192.168.7.1" > $rootdir/etc/network/interfaces
|
||||||
|
|
||||||
hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
|
hexarray=( 1 2 3 4 5 6 7 8 9 0 a b c d e f )
|
||||||
a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
a=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
||||||
b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
b=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
||||||
c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
c=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
||||||
d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
d=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
||||||
e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
e=${hexarray[$RANDOM%16]}${hexarray[$RANDOM%16]}
|
||||||
sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" \
|
sed -i "s|#hwaddress ether.*|hwaddress ether de:$a:$b:$c:$d:$e|g" \
|
||||||
$rootdir/etc/network/interfaces
|
$rootdir/etc/network/interfaces
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $rootdir/etc/resolv.conf
|
sed -i "s/nameserver.*/nameserver $NAMESERVER1/g" $rootdir/etc/resolv.conf
|
||||||
sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $rootdir/etc/resolv.conf
|
sed -i "/nameserver $NAMESERVER1/a\nameserver $NAMESERVER2" $rootdir/etc/resolv.conf
|
||||||
|
|
||||||
# change the motd to show further install instructions
|
# change the motd to show further install instructions
|
||||||
echo $"
|
echo $"
|
||||||
.---. . .
|
.---. . .
|
||||||
| | |
|
| | |
|
||||||
|--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
||||||
|
@ -203,57 +204,57 @@ following commands, then enter your details.
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_ssh() {
|
configure_ssh() {
|
||||||
sed -i "s/Port .*/Port ${SSH_PORT}/g" $rootdir/etc/ssh/sshd_config
|
sed -i "s/Port .*/Port ${SSH_PORT}/g" $rootdir/etc/ssh/sshd_config
|
||||||
|
|
||||||
if [[ "$SSH_PUBKEY" != "no" ]]; then
|
if [[ "$SSH_PUBKEY" != "no" ]]; then
|
||||||
if [ ! -d $rootdir/home/$MY_USERNAME/.ssh ]; then
|
if [ ! -d $rootdir/home/$MY_USERNAME/.ssh ]; then
|
||||||
mkdir $rootdir/home/$MY_USERNAME/.ssh
|
mkdir $rootdir/home/$MY_USERNAME/.ssh
|
||||||
fi
|
fi
|
||||||
echo "$SSH_PUBKEY" > $rootdir/home/$MY_USERNAME/.ssh/authorized_keys
|
echo "$SSH_PUBKEY" > $rootdir/home/$MY_USERNAME/.ssh/authorized_keys
|
||||||
chroot $rootdir chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
|
chroot $rootdir chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
|
||||||
sed -i 's|PasswordAuthentication.*|PasswordAuthentication no|g' $rootdir/etc/ssh/sshd_config
|
sed -i 's|PasswordAuthentication.*|PasswordAuthentication no|g' $rootdir/etc/ssh/sshd_config
|
||||||
echo $"Using ssh public key:"
|
echo $"Using ssh public key:"
|
||||||
echo $SSH_PUBKEY
|
echo $SSH_PUBKEY
|
||||||
echo $'Password ssh authentication turned off'
|
echo $'Password ssh authentication turned off'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
admin_user_sudo() {
|
admin_user_sudo() {
|
||||||
echo "$MY_USERNAME ALL=(ALL) ALL" >> $rootdir/etc/sudoers
|
echo "$MY_USERNAME ALL=(ALL) ALL" >> $rootdir/etc/sudoers
|
||||||
}
|
}
|
||||||
|
|
||||||
create_generic_image() {
|
create_generic_image() {
|
||||||
if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
|
if [[ $DEBIAN_INSTALL_ONLY != "no" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [[ $GENERIC_IMAGE == "no" ]]; then
|
if [[ $GENERIC_IMAGE == "no" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
VARIANT="full"
|
VARIANT="full"
|
||||||
if [ $CONFIG_FILENAME ]; then
|
if [ $CONFIG_FILENAME ]; then
|
||||||
if [[ "$CONFIG_FILENAME" == *"mesh.cfg"* ]]; then
|
if [[ "$CONFIG_FILENAME" == *"mesh.cfg"* ]]; then
|
||||||
VARIANT="mesh"
|
VARIANT="mesh"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Don't install any configuration. This will be a base system
|
# Don't install any configuration. This will be a base system
|
||||||
if [[ $VARIANT != "mesh" ]]; then
|
if [[ $VARIANT != "mesh" ]]; then
|
||||||
CONFIG_FILENAME=
|
CONFIG_FILENAME=
|
||||||
else
|
else
|
||||||
touch $rootdir/root/.initial_mesh_setup
|
touch $rootdir/root/.initial_mesh_setup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The presence of this file indicates that the initial
|
# The presence of this file indicates that the initial
|
||||||
# setup has not yet been completed
|
# setup has not yet been completed
|
||||||
touch $rootdir/home/$MY_USERNAME/.initial_setup
|
touch $rootdir/home/$MY_USERNAME/.initial_setup
|
||||||
chroot $rootdir chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.initial_setup
|
chroot $rootdir chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.initial_setup
|
||||||
touch $rootdir/root/.initial_setup
|
touch $rootdir/root/.initial_setup
|
||||||
|
|
||||||
cat >> $rootdir/home/$MY_USERNAME/.bashrc <<EOF
|
cat >> $rootdir/home/$MY_USERNAME/.bashrc <<EOF
|
||||||
# initial setup of the system
|
# initial setup of the system
|
||||||
if [ -f ~/.initial_setup ]; then
|
if [ -f ~/.initial_setup ]; then
|
||||||
clear
|
clear
|
||||||
echo "
|
echo "
|
||||||
.---. . .
|
.---. . .
|
||||||
| | |
|
| | |
|
||||||
|--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
||||||
|
@ -264,183 +265,189 @@ if [ -f ~/.initial_setup ]; then
|
||||||
|
|
||||||
Please enter your password a second time.
|
Please enter your password a second time.
|
||||||
"
|
"
|
||||||
sudo su
|
sudo su
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo '# initial setup of the system' >> $rootdir/root/.bashrc
|
echo '# initial setup of the system' >> $rootdir/root/.bashrc
|
||||||
echo 'if [ -f ~/.initial_setup ]; then' >> $rootdir/root/.bashrc
|
echo 'if [ -f ~/.initial_setup ]; then' >> $rootdir/root/.bashrc
|
||||||
echo ' if [ -f ~/login.txt ]; then' >> $rootdir/root/.bashrc
|
echo ' if [ -f ~/login.txt ]; then' >> $rootdir/root/.bashrc
|
||||||
echo ' NEW_USER_PASSWORD=$(printf `cat ~/login.txt`)' >> $rootdir/root/.bashrc
|
echo ' NEW_USER_PASSWORD=$(printf `cat ~/login.txt`)' >> $rootdir/root/.bashrc
|
||||||
echo ' else' >> $rootdir/root/.bashrc
|
echo ' else' >> $rootdir/root/.bashrc
|
||||||
echo ' ENTROPY=$(cat /proc/sys/kernel/random/entropy_avail)' >> $rootdir/root/.bashrc
|
echo ' ENTROPY=$(cat /proc/sys/kernel/random/entropy_avail)' >> $rootdir/root/.bashrc
|
||||||
echo ' if [ $ENTROPY -lt 500 ]; then' >> $rootdir/root/.bashrc
|
echo ' if [ $ENTROPY -lt 500 ]; then' >> $rootdir/root/.bashrc
|
||||||
ENTROPY_MESSAGE1=$'Initial setup process'
|
ENTROPY_MESSAGE1=$'Initial setup process'
|
||||||
ENTROPY_MESSAGE2=$'Password Generation'
|
ENTROPY_MESSAGE2=$'Password Generation'
|
||||||
ENTROPY_MESSAGE3=$'WARNING: The entropy available on this system is too low to generate a password.\n\nThe installation process cannot continue.'
|
ENTROPY_MESSAGE3=$'WARNING: The entropy available on this system is too low to generate a password.\n\nThe installation process cannot continue.'
|
||||||
echo " dialog --backtitle \"${ENTROPY_MESSAGE1}\" --title \"${ENTROPY_MESSAGE2}\" --msgbox \"${ENTROPY_MESSAGE3}\" 8 50" >> $rootdir/root/.bashrc
|
echo " dialog --backtitle \"${ENTROPY_MESSAGE1}\" --title \"${ENTROPY_MESSAGE2}\" --msgbox \"${ENTROPY_MESSAGE3}\" 8 50" >> $rootdir/root/.bashrc
|
||||||
echo ' exit' >> $rootdir/root/.bashrc
|
echo ' exit' >> $rootdir/root/.bashrc
|
||||||
echo ' fi' >> $rootdir/root/.bashrc
|
echo ' fi' >> $rootdir/root/.bashrc
|
||||||
echo ' NEW_USER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"' >> $rootdir/root/.bashrc
|
echo ' NEW_USER_PASSWORD="$(openssl rand -base64 12 | cut -c1-10)"' >> $rootdir/root/.bashrc
|
||||||
echo ' fi' >> $rootdir/root/.bashrc
|
echo ' fi' >> $rootdir/root/.bashrc
|
||||||
echo ' echo "${NEW_USER_PASSWORD}" > ~/login.txt' >> $rootdir/root/.bashrc
|
echo ' echo "${NEW_USER_PASSWORD}" > ~/login.txt' >> $rootdir/root/.bashrc
|
||||||
|
|
||||||
echo ' clear' >> $rootdir/root/.bashrc
|
echo ' clear' >> $rootdir/root/.bashrc
|
||||||
echo ' echo ""' >> $rootdir/root/.bashrc
|
echo ' echo ""' >> $rootdir/root/.bashrc
|
||||||
NEW_LOGIN_PASSWORD_MESSAGE1=$'Your new login password is:'
|
NEW_LOGIN_PASSWORD_MESSAGE1=$'Your new login password is:'
|
||||||
NEW_LOGIN_PASSWORD_MESSAGE2=$'Use it whenever you wish to ssh into this system.'
|
NEW_LOGIN_PASSWORD_MESSAGE2=$'Use it whenever you wish to ssh into this system.'
|
||||||
NEW_LOGIN_PASSWORD_MESSAGE3=$'IMPORTANT: Please take a moment to enter the above password into a\npassword manager or write it down somewhere.'
|
NEW_LOGIN_PASSWORD_MESSAGE3=$'IMPORTANT: Please take a moment to enter the above password into a\npassword manager or write it down somewhere.'
|
||||||
PRESS_KEY_MESSAGE=$'Press any key to continue...'
|
PRESS_KEY_MESSAGE=$'Press any key to continue...'
|
||||||
echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE1}\"" >> $rootdir/root/.bashrc
|
echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE1}\"" >> $rootdir/root/.bashrc
|
||||||
echo ' echo ""' >> $rootdir/root/.bashrc
|
echo ' echo ""' >> $rootdir/root/.bashrc
|
||||||
echo ' toilet "${NEW_USER_PASSWORD}"' >> $rootdir/root/.bashrc
|
echo ' toilet "${NEW_USER_PASSWORD}"' >> $rootdir/root/.bashrc
|
||||||
echo ' echo ""' >> $rootdir/root/.bashrc
|
echo ' echo ""' >> $rootdir/root/.bashrc
|
||||||
echo ' echo " ${NEW_USER_PASSWORD}"' >> $rootdir/root/.bashrc
|
echo ' echo " ${NEW_USER_PASSWORD}"' >> $rootdir/root/.bashrc
|
||||||
echo ' echo ""' >> $rootdir/root/.bashrc
|
echo ' echo ""' >> $rootdir/root/.bashrc
|
||||||
echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE2}\"" >> $rootdir/root/.bashrc
|
echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE2}\"" >> $rootdir/root/.bashrc
|
||||||
echo ' echo ""' >> $rootdir/root/.bashrc
|
echo ' echo ""' >> $rootdir/root/.bashrc
|
||||||
echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE3}\"" >> $rootdir/root/.bashrc
|
echo " echo \"${NEW_LOGIN_PASSWORD_MESSAGE3}\"" >> $rootdir/root/.bashrc
|
||||||
echo ' echo ""' >> $rootdir/root/.bashrc
|
echo ' echo ""' >> $rootdir/root/.bashrc
|
||||||
echo " read -n1 -r -p \"${PRESS_KEY_MESSAGE}\" key" >> $rootdir/root/.bashrc
|
echo " read -n1 -r -p \"${PRESS_KEY_MESSAGE}\" key" >> $rootdir/root/.bashrc
|
||||||
|
|
||||||
# change the password for the admin user
|
# change the password for the admin user
|
||||||
echo -n " echo \"${MY_USERNAME}:" >> $rootdir/root/.bashrc
|
echo -n " echo \"${MY_USERNAME}:" >> $rootdir/root/.bashrc
|
||||||
echo '$(printf `cat ~/login.txt`)"|chpasswd' >> $rootdir/root/.bashrc
|
echo '$(printf `cat ~/login.txt`)"|chpasswd' >> $rootdir/root/.bashrc
|
||||||
|
|
||||||
# update before continuing
|
# update before continuing
|
||||||
echo " cd /root/${PROJECT_NAME}" >> $rootdir/root/.bashrc
|
echo " cd /root/${PROJECT_NAME}" >> $rootdir/root/.bashrc
|
||||||
echo " git stash" >> $rootdir/root/.bashrc
|
echo " git stash" >> $rootdir/root/.bashrc
|
||||||
echo " git pull" >> $rootdir/root/.bashrc
|
echo " git pull" >> $rootdir/root/.bashrc
|
||||||
echo " make install" >> $rootdir/root/.bashrc
|
echo " make install" >> $rootdir/root/.bashrc
|
||||||
|
|
||||||
if [[ $VARIANT != "mesh" ]]; then
|
if [[ $VARIANT != "mesh" ]]; then
|
||||||
if [[ $ONION_ONLY == "no" ]]; then
|
if [[ $ONION_ONLY == "no" ]]; then
|
||||||
if [[ $MINIMAL_INSTALL == "no" ]]; then
|
if [[ $MINIMAL_INSTALL == "no" ]]; then
|
||||||
echo " ${PROJECT_NAME} menuconfig-full" >> $rootdir/root/.bashrc
|
echo " ${PROJECT_NAME} menuconfig-full" >> $rootdir/root/.bashrc
|
||||||
else
|
else
|
||||||
echo " ${PROJECT_NAME} menuconfig" >> $rootdir/root/.bashrc
|
echo " ${PROJECT_NAME} menuconfig" >> $rootdir/root/.bashrc
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " ${PROJECT_NAME} menuconfig-onion" >> $rootdir/root/.bashrc
|
echo " ${PROJECT_NAME} menuconfig-onion" >> $rootdir/root/.bashrc
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " echo ''" >> $rootdir/root/.bashrc
|
echo " echo ''" >> $rootdir/root/.bashrc
|
||||||
fi
|
fi
|
||||||
echo ' if [ "$?" = "0" ]; then' >> $rootdir/root/.bashrc
|
echo ' if [ "$?" = "0" ]; then' >> $rootdir/root/.bashrc
|
||||||
echo " if [ -f ~/${PROJECT_NAME}-completed.txt ]; then" >> $rootdir/root/.bashrc
|
echo " if [ -f ~/${PROJECT_NAME}-completed.txt ]; then" >> $rootdir/root/.bashrc
|
||||||
# Remove the initial setup files
|
# Remove the initial setup files
|
||||||
echo ' rm /root/.initial_setup' >> $rootdir/root/.bashrc
|
echo ' rm /root/.initial_setup' >> $rootdir/root/.bashrc
|
||||||
echo " rm /home/${MY_USERNAME}/.initial_setup" >> $rootdir/root/.bashrc
|
echo " rm /home/${MY_USERNAME}/.initial_setup" >> $rootdir/root/.bashrc
|
||||||
echo " touch /root/.remove_${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
|
echo " touch /root/.remove_${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
|
||||||
echo ' shred -zu ~/login.txt' >> $rootdir/root/.bashrc
|
echo ' shred -zu ~/login.txt' >> $rootdir/root/.bashrc
|
||||||
END_MESSAGE1=$'Congratulations!'
|
END_MESSAGE1=$'Congratulations!'
|
||||||
if [[ $VARIANT != "mesh" ]]; then
|
if [[ $VARIANT != "mesh" ]]; then
|
||||||
END_MESSAGE2=$'\nYour system has now installed\n\nThe onion ssh service is at $SSH_ONION_HOSTNAME\n\nPress any key to reboot and begin using it'
|
END_MESSAGE2=$'\nYour system has now installed\n\nThe onion ssh service is at $SSH_ONION_HOSTNAME\n\nPress any key to reboot and begin using it'
|
||||||
echo ' SSH_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_ssh/hostname)' >> $rootdir/root/.bashrc
|
echo ' SSH_ONION_HOSTNAME=$(cat /var/lib/tor/hidden_service_ssh/hostname)' >> $rootdir/root/.bashrc
|
||||||
else
|
else
|
||||||
END_MESSAGE2=$'\nYour system has now installed\n\nPress any key to reboot and begin using it'
|
END_MESSAGE2=$'\nYour system has now installed\n\nPress any key to reboot and begin using it'
|
||||||
fi
|
fi
|
||||||
echo " dialog --title '$END_MESSAGE1' --msgbox \"$END_MESSAGE2\" 9 50" >> $rootdir/root/.bashrc
|
echo " dialog --title '$END_MESSAGE1' --msgbox \"$END_MESSAGE2\" 9 50" >> $rootdir/root/.bashrc
|
||||||
echo ' reboot' >> $rootdir/root/.bashrc
|
echo ' reboot' >> $rootdir/root/.bashrc
|
||||||
echo ' fi' >> $rootdir/root/.bashrc
|
echo ' fi' >> $rootdir/root/.bashrc
|
||||||
echo ' else' >> $rootdir/root/.bashrc
|
echo ' else' >> $rootdir/root/.bashrc
|
||||||
echo ' key=' >> $rootdir/root/.bashrc
|
echo ' key=' >> $rootdir/root/.bashrc
|
||||||
echo ' while [[ $key != "x" ]]; do' >> $rootdir/root/.bashrc
|
echo ' while [[ $key != "x" ]]; do' >> $rootdir/root/.bashrc
|
||||||
INSTALL_FAIL_MESSAGE=$"Install failed. Press x to continue..."
|
INSTALL_FAIL_MESSAGE=$"Install failed. Press x to continue..."
|
||||||
echo " read -n1 -r -p \"${INSTALL_FAIL_MESSAGE}\" key" >> $rootdir/root/.bashrc
|
echo " read -n1 -r -p \"${INSTALL_FAIL_MESSAGE}\" key" >> $rootdir/root/.bashrc
|
||||||
echo ' done' >> $rootdir/root/.bashrc
|
echo ' done' >> $rootdir/root/.bashrc
|
||||||
echo ' fi' >> $rootdir/root/.bashrc
|
echo ' fi' >> $rootdir/root/.bashrc
|
||||||
echo ' exit' >> $rootdir/root/.bashrc
|
echo ' exit' >> $rootdir/root/.bashrc
|
||||||
echo 'else' >> $rootdir/root/.bashrc
|
echo 'else' >> $rootdir/root/.bashrc
|
||||||
echo ' # Remove default account after install' >> $rootdir/root/.bashrc
|
echo ' # Remove default account after install' >> $rootdir/root/.bashrc
|
||||||
echo " if [ -f /root/.remove_${GENERIC_IMAGE_USERNAME} ]; then" >> $rootdir/root/.bashrc
|
echo " if [ -f /root/.remove_${GENERIC_IMAGE_USERNAME} ]; then" >> $rootdir/root/.bashrc
|
||||||
echo " if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then" >> $rootdir/root/.bashrc
|
echo " if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then" >> $rootdir/root/.bashrc
|
||||||
echo " userdel -r ${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
|
echo " userdel -r ${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
|
||||||
echo " if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then" >> $rootdir/root/.bashrc
|
echo " if [ -d /home/${GENERIC_IMAGE_USERNAME} ]; then" >> $rootdir/root/.bashrc
|
||||||
echo " rm -rf /home/${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
|
echo " rm -rf /home/${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
|
||||||
echo " rm /root/.remove_${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
|
echo " rm /root/.remove_${GENERIC_IMAGE_USERNAME}" >> $rootdir/root/.bashrc
|
||||||
echo ' fi' >> $rootdir/root/.bashrc
|
echo ' fi' >> $rootdir/root/.bashrc
|
||||||
echo ' fi' >> $rootdir/root/.bashrc
|
echo ' fi' >> $rootdir/root/.bashrc
|
||||||
echo ' fi' >> $rootdir/root/.bashrc
|
echo ' fi' >> $rootdir/root/.bashrc
|
||||||
echo 'fi' >> $rootdir/root/.bashrc
|
echo 'fi' >> $rootdir/root/.bashrc
|
||||||
}
|
}
|
||||||
|
|
||||||
continue_installation() {
|
continue_installation() {
|
||||||
# If a configuration file exists then run with it
|
# If a configuration file exists then run with it
|
||||||
# otherwise the interactive installer can be used
|
# otherwise the interactive installer can be used
|
||||||
# This is equivalent to installing freedombox-setup on freedombox
|
# This is equivalent to installing freedombox-setup on freedombox
|
||||||
if [ $CONFIG_FILENAME ]; then
|
if [ $CONFIG_FILENAME ]; then
|
||||||
if [ ${#CONFIG_FILENAME} -gt 2 ]; then
|
if [ ${#CONFIG_FILENAME} -gt 2 ]; then
|
||||||
cp $CONFIG_FILENAME $rootdir/root/$PROJECT_NAME.cfg
|
cp $CONFIG_FILENAME $rootdir/root/$PROJECT_NAME.cfg
|
||||||
cat $rootdir/root/$PROJECT_NAME.cfg
|
cat $rootdir/root/$PROJECT_NAME.cfg
|
||||||
chroot "$rootdir" su -c "$PROJECT_NAME -c /root/$PROJECT_NAME.cfg" - root
|
chroot "$rootdir" su -c "$PROJECT_NAME -c /root/$PROJECT_NAME.cfg" - root
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
atheros_wifi() {
|
atheros_wifi() {
|
||||||
firmware_filename="open-ath9k-htc-firmware_1.3-1_all.deb"
|
firmware_filename="open-ath9k-htc-firmware_1.3-1_all.deb"
|
||||||
firmware_hash='5fea58ffefdf0ef15b504db7fbe3bc078c03e0d927bba64085e4b6f2546102f5'
|
firmware_hash='5fea58ffefdf0ef15b504db7fbe3bc078c03e0d927bba64085e4b6f2546102f5'
|
||||||
|
|
||||||
firmware_url="http://us.archive.trisquel.info/trisquel/pool/main/o/open-ath9k-htc-firmware/$firmware_filename"
|
firmware_url="http://us.archive.trisquel.info/trisquel/pool/main/o/open-ath9k-htc-firmware/$firmware_filename"
|
||||||
firmware_tempfile="/tmp/$firmware_filename"
|
firmware_tempfile="/tmp/$firmware_filename"
|
||||||
wget "$firmware_url" -O "$rootdir$firmware_tempfile"
|
wget "$firmware_url" -O "$rootdir$firmware_tempfile"
|
||||||
downloaded_firmware_hash=$(sha256sum "$rootdir$firmware_tempfile" | awk -F ' ' '{print $1}')
|
downloaded_firmware_hash=$(sha256sum "$rootdir$firmware_tempfile" | awk -F ' ' '{print $1}')
|
||||||
if [[ "$downloaded_firmware_hash" == "$firmware_hash" ]]; then
|
if [[ "$downloaded_firmware_hash" == "$firmware_hash" ]]; then
|
||||||
chroot "$rootdir" dpkg -i "$firmware_tempfile"
|
chroot "$rootdir" dpkg -i "$firmware_tempfile"
|
||||||
else
|
else
|
||||||
echo 'WARNING: Atheros Wifi firmware hash does not match. The driver has not been installed.'
|
echo 'WARNING: Atheros Wifi firmware hash does not match. The driver has not been installed.'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
initialise_mesh() {
|
initialise_mesh() {
|
||||||
if [[ $VARIANT != "mesh" || $DEBIAN_INSTALL_ONLY != "no" ]]; then
|
if [[ $VARIANT != "mesh" || $DEBIAN_INSTALL_ONLY != "no" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
freedombone-mesh-install -f firewall -r "${rootdir}"
|
freedombone-mesh-install -f firewall -r "${rootdir}"
|
||||||
freedombone-mesh-install -f avahi -r "${rootdir}"
|
freedombone-mesh-install -f avahi -r "${rootdir}"
|
||||||
freedombone-mesh-install -f batman -r "${rootdir}"
|
freedombone-mesh-install -f batman -r "${rootdir}"
|
||||||
freedombone-mesh-install -f tox_node -r "${rootdir}"
|
freedombone-mesh-install -f tox_node -r "${rootdir}"
|
||||||
freedombone-mesh-install -f tox_client -r "${rootdir}"
|
freedombone-mesh-install -f tox_client -r "${rootdir}"
|
||||||
freedombone-mesh-install -f zeronet -r "${rootdir}"
|
freedombone-mesh-install -f zeronet -r "${rootdir}"
|
||||||
|
|
||||||
MESH_SERVICE='mesh-setup.service'
|
MESH_SERVICE='mesh-setup.service'
|
||||||
MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE
|
MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE
|
||||||
|
|
||||||
echo '[Unit]' > $MESH_SETUP_DAEMON
|
echo '[Unit]' > $MESH_SETUP_DAEMON
|
||||||
echo 'Description=Initial mesh router configuration' >> $MESH_SETUP_DAEMON
|
echo 'Description=Initial mesh router configuration' >> $MESH_SETUP_DAEMON
|
||||||
echo 'After=syslog.target' >> $MESH_SETUP_DAEMON
|
echo 'After=syslog.target' >> $MESH_SETUP_DAEMON
|
||||||
echo 'After=network.target' >> $MESH_SETUP_DAEMON
|
echo 'After=network.target' >> $MESH_SETUP_DAEMON
|
||||||
echo '[Service]' >> $MESH_SETUP_DAEMON
|
echo '[Service]' >> $MESH_SETUP_DAEMON
|
||||||
echo 'Type=simple' >> $MESH_SETUP_DAEMON
|
echo 'Type=simple' >> $MESH_SETUP_DAEMON
|
||||||
echo 'User=root' >> $MESH_SETUP_DAEMON
|
echo 'User=root' >> $MESH_SETUP_DAEMON
|
||||||
echo 'Group=root' >> $MESH_SETUP_DAEMON
|
echo 'Group=root' >> $MESH_SETUP_DAEMON
|
||||||
echo 'WorkingDirectory=/root' >> $MESH_SETUP_DAEMON
|
echo 'WorkingDirectory=/root' >> $MESH_SETUP_DAEMON
|
||||||
echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-image-mesh > /var/log/mesh-setup.log" >> $MESH_SETUP_DAEMON
|
echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-image-mesh > /var/log/mesh-setup.log" >> $MESH_SETUP_DAEMON
|
||||||
echo '' >> $MESH_SETUP_DAEMON
|
echo '' >> $MESH_SETUP_DAEMON
|
||||||
echo 'TimeoutSec=99999' >> $MESH_SETUP_DAEMON
|
echo 'TimeoutSec=99999' >> $MESH_SETUP_DAEMON
|
||||||
echo '' >> $MESH_SETUP_DAEMON
|
echo '' >> $MESH_SETUP_DAEMON
|
||||||
echo '[Install]' >> $MESH_SETUP_DAEMON
|
echo '[Install]' >> $MESH_SETUP_DAEMON
|
||||||
echo 'WantedBy=multi-user.target' >> $MESH_SETUP_DAEMON
|
echo 'WantedBy=multi-user.target' >> $MESH_SETUP_DAEMON
|
||||||
chroot "$rootdir" systemctl enable $MESH_SERVICE
|
chroot "$rootdir" systemctl enable $MESH_SERVICE
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_wifi() {
|
configure_wifi() {
|
||||||
if [[ $VARIANT == "mesh" ]]; then
|
if [[ $VARIANT == "mesh" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [[ $WIFI_TYPE != 'none' ]]; then
|
|
||||||
if [ ! $WIFI_PASSPHRASE ]; then
|
if [ -f $WIFI_NETWORKS_FILE ]; then
|
||||||
return
|
chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE --networks $WIFI_NETWORKS_FILE
|
||||||
fi
|
return
|
||||||
if [ ${#WIFI_PASSPHRASE} -lt 2 ]; then
|
fi
|
||||||
return
|
|
||||||
fi
|
if [[ $WIFI_TYPE != 'none' ]]; then
|
||||||
chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $HOTSPOT
|
if [ ! $WIFI_PASSPHRASE ]; then
|
||||||
else
|
return
|
||||||
chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE --hotspot $HOTSPOT
|
fi
|
||||||
fi
|
if [ ${#WIFI_PASSPHRASE} -lt 2 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $HOTSPOT
|
||||||
|
else
|
||||||
|
chroot "$rootdir" ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE --hotspot $HOTSPOT
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set to true/false to control if eatmydata is used during build
|
# Set to true/false to control if eatmydata is used during build
|
||||||
|
@ -468,16 +475,16 @@ echo $username:$password | chroot $rootdir /usr/sbin/chpasswd
|
||||||
chroot "$rootdir" adduser $username sudo
|
chroot "$rootdir" adduser $username sudo
|
||||||
|
|
||||||
case "$MACHINE" in
|
case "$MACHINE" in
|
||||||
virtualbox)
|
virtualbox)
|
||||||
# hide irrelevant console keyboard messages.
|
# hide irrelevant console keyboard messages.
|
||||||
echo "echo \"4 4 1 7\" > /proc/sys/kernel/printk" \
|
echo "echo \"4 4 1 7\" > /proc/sys/kernel/printk" \
|
||||||
>> /etc/init.d/rc.local
|
>> /etc/init.d/rc.local
|
||||||
;;
|
;;
|
||||||
qemu)
|
qemu)
|
||||||
# hide irrelevant console keyboard messages.
|
# hide irrelevant console keyboard messages.
|
||||||
echo "echo \"4 4 1 7\" > /proc/sys/kernel/printk" \
|
echo "echo \"4 4 1 7\" > /proc/sys/kernel/printk" \
|
||||||
>> /etc/init.d/rc.local
|
>> /etc/init.d/rc.local
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
set_apt_sources $BUILD_MIRROR
|
set_apt_sources $BUILD_MIRROR
|
||||||
|
@ -487,19 +494,19 @@ chroot "$rootdir" apt-get clean
|
||||||
chroot "$rootdir" apt-get update
|
chroot "$rootdir" apt-get update
|
||||||
|
|
||||||
cat > $rootdir/usr/sbin/policy-rc.d <<EOF
|
cat > $rootdir/usr/sbin/policy-rc.d <<EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exit 101
|
exit 101
|
||||||
EOF
|
EOF
|
||||||
chmod a+rx $rootdir/usr/sbin/policy-rc.d
|
chmod a+rx $rootdir/usr/sbin/policy-rc.d
|
||||||
|
|
||||||
if $use_eatmydata ; then
|
if $use_eatmydata ; then
|
||||||
enable_eatmydata_override
|
enable_eatmydata_override
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$CUSTOM_SETUP" ]; then
|
if [ -n "$CUSTOM_SETUP" ]; then
|
||||||
cp "$CUSTOM_SETUP" "$rootdir"/tmp
|
cp "$CUSTOM_SETUP" "$rootdir"/tmp
|
||||||
chroot "$rootdir" apt-get install -y gdebi-core
|
chroot "$rootdir" apt-get install -y gdebi-core
|
||||||
chroot "$rootdir" gdebi -n /tmp/"$(basename $CUSTOM_SETUP)"
|
chroot "$rootdir" gdebi -n /tmp/"$(basename $CUSTOM_SETUP)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chroot "$rootdir" apt-get install -y sudo git dialog toilet build-essential openssh-server
|
chroot "$rootdir" apt-get install -y sudo git dialog toilet build-essential openssh-server
|
||||||
|
@ -511,45 +518,45 @@ chroot "$rootdir" apt-get install -y locales locales-all debconf wireless-tools
|
||||||
sed -i "s|#host-name=.*|host-name=${PROJECT_NAME}|g" $rootdir/etc/avahi/avahi-daemon.conf
|
sed -i "s|#host-name=.*|host-name=${PROJECT_NAME}|g" $rootdir/etc/avahi/avahi-daemon.conf
|
||||||
|
|
||||||
chroot "$rootdir" /bin/bash -x <<EOF
|
chroot "$rootdir" /bin/bash -x <<EOF
|
||||||
git clone $PROJECT_REPO /root/$PROJECT_NAME
|
git clone $PROJECT_REPO /root/$PROJECT_NAME
|
||||||
cd /root/$PROJECT_NAME
|
cd /root/$PROJECT_NAME
|
||||||
make install
|
make install
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chroot "$rootdir" ${PROJECT_NAME}-image-hardware-setup 2>&1 | \
|
chroot "$rootdir" ${PROJECT_NAME}-image-hardware-setup 2>&1 | \
|
||||||
tee $rootdir/var/log/${PROJECT_NAME}-image-hardware-setup.log
|
tee $rootdir/var/log/${PROJECT_NAME}-image-hardware-setup.log
|
||||||
|
|
||||||
rm $rootdir/usr/sbin/policy-rc.d
|
rm $rootdir/usr/sbin/policy-rc.d
|
||||||
|
|
||||||
# Set up HRNG for systems known to have one
|
# Set up HRNG for systems known to have one
|
||||||
# Otherwise install haveged
|
# Otherwise install haveged
|
||||||
if [[ "$MACHINE" != "beaglebone" ]]; then
|
if [[ "$MACHINE" != "beaglebone" ]]; then
|
||||||
chroot $rootdir apt-get -y install haveged
|
chroot $rootdir apt-get -y install haveged
|
||||||
else
|
else
|
||||||
chroot $rootdir apt-get -y install rng-tools
|
chroot $rootdir apt-get -y install rng-tools
|
||||||
sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' $rootdir/etc/default/rng-tools
|
sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' $rootdir/etc/default/rng-tools
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# copy u-boot to beginning of image
|
# copy u-boot to beginning of image
|
||||||
case "$MACHINE" in
|
case "$MACHINE" in
|
||||||
beaglebone)
|
beaglebone)
|
||||||
dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/MLO of="$image" \
|
dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/MLO of="$image" \
|
||||||
count=1 seek=1 conv=notrunc bs=128k
|
count=1 seek=1 conv=notrunc bs=128k
|
||||||
dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/u-boot.img of="$image" \
|
dd if=$rootdir/usr/lib/u-boot/am335x_boneblack/u-boot.img of="$image" \
|
||||||
count=2 seek=1 conv=notrunc bs=384k
|
count=2 seek=1 conv=notrunc bs=384k
|
||||||
;;
|
;;
|
||||||
cubieboard2)
|
cubieboard2)
|
||||||
dd if=$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin of="$image" \
|
dd if=$rootdir/usr/lib/u-boot/Cubieboard2/u-boot-sunxi-with-spl.bin of="$image" \
|
||||||
seek=8 conv=notrunc bs=1k
|
seek=8 conv=notrunc bs=1k
|
||||||
;;
|
;;
|
||||||
a20-olinuxino-lime)
|
a20-olinuxino-lime)
|
||||||
dd if=$rootdir/usr/lib/u-boot/A20-OLinuXino-Lime/u-boot-sunxi-with-spl.bin \
|
dd if=$rootdir/usr/lib/u-boot/A20-OLinuXino-Lime/u-boot-sunxi-with-spl.bin \
|
||||||
of="$image" seek=8 conv=notrunc bs=1k
|
of="$image" seek=8 conv=notrunc bs=1k
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if $use_eatmydata ; then
|
if $use_eatmydata ; then
|
||||||
disable_eatmydata_override
|
disable_eatmydata_override
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set_apt_sources $MIRROR
|
set_apt_sources $MIRROR
|
||||||
|
|
|
@ -61,6 +61,7 @@ export WIFI_SSID
|
||||||
export WIFI_TYPE
|
export WIFI_TYPE
|
||||||
export WIFI_PASSPHRASE
|
export WIFI_PASSPHRASE
|
||||||
export WIFI_HOTSPOT
|
export WIFI_HOTSPOT
|
||||||
|
export WIFI_NETWORKS_FILE
|
||||||
|
|
||||||
# Locate vmdebootstrap program fetched in Makefile
|
# Locate vmdebootstrap program fetched in Makefile
|
||||||
basedir=`pwd`
|
basedir=`pwd`
|
||||||
|
@ -181,6 +182,7 @@ sudo sed -i "s|WIFI_SSID=.*|WIFI_SSID=\"${WIFI_SSID}\"|g" $TEMP_CUSTOMISE
|
||||||
sudo sed -i "s|WIFI_TYPE=.*|WIFI_TYPE=\"${WIFI_TYPE}\"|g" $TEMP_CUSTOMISE
|
sudo sed -i "s|WIFI_TYPE=.*|WIFI_TYPE=\"${WIFI_TYPE}\"|g" $TEMP_CUSTOMISE
|
||||||
sudo sed -i "s|WIFI_PASSPHRASE=.*|WIFI_PASSPHRASE=\"${WIFI_PASSPHRASE}\"|g" $TEMP_CUSTOMISE
|
sudo sed -i "s|WIFI_PASSPHRASE=.*|WIFI_PASSPHRASE=\"${WIFI_PASSPHRASE}\"|g" $TEMP_CUSTOMISE
|
||||||
sudo sed -i "s|WIFI_HOTSPOT=.*|WIFI_HOTSPOT=\"${WIFI_HOTSPOT}\"|g" $TEMP_CUSTOMISE
|
sudo sed -i "s|WIFI_HOTSPOT=.*|WIFI_HOTSPOT=\"${WIFI_HOTSPOT}\"|g" $TEMP_CUSTOMISE
|
||||||
|
sudo sed -i "s|WIFI_NETWORKS_FILE=.*|WIFI_NETWORKS_FILE=\"${WIFI_NETWORKS_FILE}\"|g" $TEMP_CUSTOMISE
|
||||||
|
|
||||||
echo $"starting $VMDEBOOTSTRAP"
|
echo $"starting $VMDEBOOTSTRAP"
|
||||||
# Run vmdebootstrap script to create image
|
# Run vmdebootstrap script to create image
|
||||||
|
|
|
@ -42,314 +42,314 @@ WIFI_SSID=
|
||||||
WIFI_PASSPHRASE=
|
WIFI_PASSPHRASE=
|
||||||
WIFI_HOTSPOT='no'
|
WIFI_HOTSPOT='no'
|
||||||
WIFI_CONFIG=/etc/wpa_supplicant/wpa_supplicant.conf
|
WIFI_CONFIG=/etc/wpa_supplicant/wpa_supplicant.conf
|
||||||
WIFI_FILE=/root/${PROJECT_NAME}-wifi.cfg
|
WIFI_NETWORKS_FILE=/root/${PROJECT_NAME}-wifi.cfg
|
||||||
|
|
||||||
function wifi_get_psk {
|
function wifi_get_psk {
|
||||||
ssid=$1
|
ssid=$1
|
||||||
passphrase=$2
|
passphrase=$2
|
||||||
|
|
||||||
psk=$(wpa_passphrase "$ssid" "$passphrase" | grep 'psk=' | sed -n 2p | awk -F '=' '{print $2}')
|
psk=$(wpa_passphrase "$ssid" "$passphrase" | grep 'psk=' | sed -n 2p | awk -F '=' '{print $2}')
|
||||||
echo $psk
|
echo $psk
|
||||||
}
|
}
|
||||||
|
|
||||||
function hotspot_off {
|
function hotspot_off {
|
||||||
if [ ! -f /etc/hostapd/hostapd.conf ]; then
|
if [ ! -f /etc/hostapd/hostapd.conf ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
systemctl stop hostapd
|
systemctl stop hostapd
|
||||||
|
|
||||||
rm /etc/hostapd/hostapd.conf
|
rm /etc/hostapd/hostapd.conf
|
||||||
|
|
||||||
if [ -f /etc/network/interfaces_original ]; then
|
if [ -f /etc/network/interfaces_original ]; then
|
||||||
cp /etc/network/interfaces_original /etc/network/interfaces
|
cp /etc/network/interfaces_original /etc/network/interfaces
|
||||||
else
|
else
|
||||||
echo '# interfaces(5) file used by ifup(8) and ifdown(8)' > /etc/network/interfaces
|
echo '# interfaces(5) file used by ifup(8) and ifdown(8)' > /etc/network/interfaces
|
||||||
echo '# Include files from /etc/network/interfaces.d:' >> /etc/network/interfaces
|
echo '# Include files from /etc/network/interfaces.d:' >> /etc/network/interfaces
|
||||||
echo 'source-directory /etc/network/interfaces.d' >> /etc/network/interfaces
|
echo 'source-directory /etc/network/interfaces.d' >> /etc/network/interfaces
|
||||||
fi
|
fi
|
||||||
|
|
||||||
systemctl restart network-manager
|
systemctl restart network-manager
|
||||||
}
|
}
|
||||||
|
|
||||||
function hotspot_on {
|
function hotspot_on {
|
||||||
if [ ! -f /etc/default/hostapd ]; then
|
if [ ! -f /etc/default/hostapd ]; then
|
||||||
echo $'/etc/default/hostapd was not found'
|
echo $'/etc/default/hostapd was not found'
|
||||||
exit 67241
|
exit 67241
|
||||||
fi
|
fi
|
||||||
if [ ${#WIFI_PASSPHRASE} -lt 8 ]; then
|
if [ ${#WIFI_PASSPHRASE} -lt 8 ]; then
|
||||||
echo $'Wifi hotspot passphrase is too short'
|
echo $'Wifi hotspot passphrase is too short'
|
||||||
exit 25719
|
exit 25719
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i 's|#DAEMON_CONF=.*|DAEMON_CONF="/etc/hostapd/hostapd.conf"|g' /etc/default/hostapd
|
sed -i 's|#DAEMON_CONF=.*|DAEMON_CONF="/etc/hostapd/hostapd.conf"|g' /etc/default/hostapd
|
||||||
|
|
||||||
echo '### Wireless network name ###' > /etc/hostapd/hostapd.conf
|
echo '### Wireless network name ###' > /etc/hostapd/hostapd.conf
|
||||||
echo "interface=$WIFI_INTERFACE" >> /etc/hostapd/hostapd.conf
|
echo "interface=$WIFI_INTERFACE" >> /etc/hostapd/hostapd.conf
|
||||||
echo '' >> /etc/hostapd/hostapd.conf
|
echo '' >> /etc/hostapd/hostapd.conf
|
||||||
echo '### Set your bridge name ###' >> /etc/hostapd/hostapd.conf
|
echo '### Set your bridge name ###' >> /etc/hostapd/hostapd.conf
|
||||||
echo 'bridge=br0' >> /etc/hostapd/hostapd.conf
|
echo 'bridge=br0' >> /etc/hostapd/hostapd.conf
|
||||||
echo '' >> /etc/hostapd/hostapd.conf
|
echo '' >> /etc/hostapd/hostapd.conf
|
||||||
echo 'driver=nl80211' >> /etc/hostapd/hostapd.conf
|
echo 'driver=nl80211' >> /etc/hostapd/hostapd.conf
|
||||||
echo "country_code=UK" >> /etc/hostapd/hostapd.conf
|
echo "country_code=UK" >> /etc/hostapd/hostapd.conf
|
||||||
echo "ssid=$WIFI_SSID" >> /etc/hostapd/hostapd.conf
|
echo "ssid=$WIFI_SSID" >> /etc/hostapd/hostapd.conf
|
||||||
echo 'hw_mode=g' >> /etc/hostapd/hostapd.conf
|
echo 'hw_mode=g' >> /etc/hostapd/hostapd.conf
|
||||||
echo 'channel=6' >> /etc/hostapd/hostapd.conf
|
echo 'channel=6' >> /etc/hostapd/hostapd.conf
|
||||||
echo 'wpa=2' >> /etc/hostapd/hostapd.conf
|
echo 'wpa=2' >> /etc/hostapd/hostapd.conf
|
||||||
echo "wpa_passphrase=$WIFI_PASSPHRASE" >> /etc/hostapd/hostapd.conf
|
echo "wpa_passphrase=$WIFI_PASSPHRASE" >> /etc/hostapd/hostapd.conf
|
||||||
echo '' >> /etc/hostapd/hostapd.conf
|
echo '' >> /etc/hostapd/hostapd.conf
|
||||||
echo '## Key management algorithms ##' >> /etc/hostapd/hostapd.conf
|
echo '## Key management algorithms ##' >> /etc/hostapd/hostapd.conf
|
||||||
echo 'wpa_key_mgmt=WPA-PSK' >> /etc/hostapd/hostapd.conf
|
echo 'wpa_key_mgmt=WPA-PSK' >> /etc/hostapd/hostapd.conf
|
||||||
echo '' >> /etc/hostapd/hostapd.conf
|
echo '' >> /etc/hostapd/hostapd.conf
|
||||||
echo '## Set cipher suites (encryption algorithms) ##' >> /etc/hostapd/hostapd.conf
|
echo '## Set cipher suites (encryption algorithms) ##' >> /etc/hostapd/hostapd.conf
|
||||||
echo '## TKIP = Temporal Key Integrity Protocol' >> /etc/hostapd/hostapd.conf
|
echo '## TKIP = Temporal Key Integrity Protocol' >> /etc/hostapd/hostapd.conf
|
||||||
echo '## CCMP = AES in Counter mode with CBC-MAC' >> /etc/hostapd/hostapd.conf
|
echo '## CCMP = AES in Counter mode with CBC-MAC' >> /etc/hostapd/hostapd.conf
|
||||||
echo 'wpa_pairwise=TKIP' >> /etc/hostapd/hostapd.conf
|
echo 'wpa_pairwise=TKIP' >> /etc/hostapd/hostapd.conf
|
||||||
echo 'rsn_pairwise=CCMP' >> /etc/hostapd/hostapd.conf
|
echo 'rsn_pairwise=CCMP' >> /etc/hostapd/hostapd.conf
|
||||||
echo '' >> /etc/hostapd/hostapd.conf
|
echo '' >> /etc/hostapd/hostapd.conf
|
||||||
echo '## Shared Key Authentication ##'
|
echo '## Shared Key Authentication ##'
|
||||||
echo 'auth_algs=1'
|
echo 'auth_algs=1'
|
||||||
echo '' >> /etc/hostapd/hostapd.conf
|
echo '' >> /etc/hostapd/hostapd.conf
|
||||||
echo '## Accept all MAC address ###' >> /etc/hostapd/hostapd.conf
|
echo '## Accept all MAC address ###' >> /etc/hostapd/hostapd.conf
|
||||||
echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
|
echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
|
||||||
|
|
||||||
if [ ! -f /etc/network/interfaces_original ]; then
|
if [ ! -f /etc/network/interfaces_original ]; then
|
||||||
if ! grep -q "# wifi enabled" /etc/network/interfaces; then
|
if ! grep -q "# wifi enabled" /etc/network/interfaces; then
|
||||||
cp /etc/network/interfaces /etc/network/interfaces_original
|
cp /etc/network/interfaces /etc/network/interfaces_original
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '# wifi enabled' > /etc/network/interfaces
|
echo '# wifi enabled' > /etc/network/interfaces
|
||||||
echo 'auto lo br0' >> /etc/network/interfaces
|
echo 'auto lo br0' >> /etc/network/interfaces
|
||||||
echo 'iface lo inet loopback' >> /etc/network/interfaces
|
echo 'iface lo inet loopback' >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo "# wireless $WIFI_INTERFACE" >> /etc/network/interfaces
|
echo "# wireless $WIFI_INTERFACE" >> /etc/network/interfaces
|
||||||
echo "allow-hotplug $WIFI_INTERFACE" >> /etc/network/interfaces
|
echo "allow-hotplug $WIFI_INTERFACE" >> /etc/network/interfaces
|
||||||
echo "iface $WIFI_INTERFACE inet manual" >> /etc/network/interfaces
|
echo "iface $WIFI_INTERFACE inet manual" >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo '# eth0 connected to the ISP router' >> /etc/network/interfaces
|
echo '# eth0 connected to the ISP router' >> /etc/network/interfaces
|
||||||
echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
||||||
echo 'iface eth0 inet manual' >> /etc/network/interfaces
|
echo 'iface eth0 inet manual' >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo '# Setup bridge' >> /etc/network/interfaces
|
echo '# Setup bridge' >> /etc/network/interfaces
|
||||||
echo 'iface br0 inet static' >> /etc/network/interfaces
|
echo 'iface br0 inet static' >> /etc/network/interfaces
|
||||||
echo " bridge_ports $WIFI_INTERFACE eth0" >> /etc/network/interfaces
|
echo " bridge_ports $WIFI_INTERFACE eth0" >> /etc/network/interfaces
|
||||||
|
|
||||||
systemctl restart network-manager
|
systemctl restart network-manager
|
||||||
systemctl restart hostapd
|
systemctl restart hostapd
|
||||||
}
|
}
|
||||||
|
|
||||||
function wifi_wpa2_psk {
|
function wifi_wpa2_psk {
|
||||||
ssid=$1
|
ssid=$1
|
||||||
passphrase=$2
|
passphrase=$2
|
||||||
|
|
||||||
if [ ! -f /etc/network/interfaces_original ]; then
|
if [ ! -f /etc/network/interfaces_original ]; then
|
||||||
if ! grep -q "# wifi enabled" /etc/network/interfaces; then
|
if ! grep -q "# wifi enabled" /etc/network/interfaces; then
|
||||||
cp /etc/network/interfaces /etc/network/interfaces_original
|
cp /etc/network/interfaces /etc/network/interfaces_original
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '# wifi enabled' > /etc/network/interfaces
|
echo '# wifi enabled' > /etc/network/interfaces
|
||||||
echo 'auto lo' >> /etc/network/interfaces
|
echo 'auto lo' >> /etc/network/interfaces
|
||||||
echo 'iface lo inet loopback' >> /etc/network/interfaces
|
echo 'iface lo inet loopback' >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
||||||
echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
|
echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo 'allow-hotplug wlan0' >> /etc/network/interfaces
|
echo 'allow-hotplug wlan0' >> /etc/network/interfaces
|
||||||
echo 'iface wlan0 inet manual' >> /etc/network/interfaces
|
echo 'iface wlan0 inet manual' >> /etc/network/interfaces
|
||||||
echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces
|
echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo 'iface default inet dhcp' >> /etc/network/interfaces
|
echo 'iface default inet dhcp' >> /etc/network/interfaces
|
||||||
|
|
||||||
wpa_passphrase "$ssid" "$passphrase" > $WIFI_CONFIG
|
wpa_passphrase "$ssid" "$passphrase" > $WIFI_CONFIG
|
||||||
|
|
||||||
systemctl restart network-manager
|
systemctl restart network-manager
|
||||||
}
|
}
|
||||||
|
|
||||||
function wifi_none {
|
function wifi_none {
|
||||||
ssid=$1
|
ssid=$1
|
||||||
|
|
||||||
if [ ! -f /etc/network/interfaces_original ]; then
|
if [ ! -f /etc/network/interfaces_original ]; then
|
||||||
if ! grep -q "# wifi enabled" /etc/network/interfaces; then
|
if ! grep -q "# wifi enabled" /etc/network/interfaces; then
|
||||||
cp /etc/network/interfaces /etc/network/interfaces_original
|
cp /etc/network/interfaces /etc/network/interfaces_original
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '# wifi enabled' > /etc/network/interfaces
|
echo '# wifi enabled' > /etc/network/interfaces
|
||||||
echo 'auto lo' >> /etc/network/interfaces
|
echo 'auto lo' >> /etc/network/interfaces
|
||||||
echo 'iface lo inet loopback' >> /etc/network/interfaces
|
echo 'iface lo inet loopback' >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
||||||
echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
|
echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo 'allow-hotplug wlan0' >> /etc/network/interfaces
|
echo 'allow-hotplug wlan0' >> /etc/network/interfaces
|
||||||
echo 'iface wlan0 inet manual' >> /etc/network/interfaces
|
echo 'iface wlan0 inet manual' >> /etc/network/interfaces
|
||||||
echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces
|
echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo 'iface default inet dhcp' >> /etc/network/interfaces
|
echo 'iface default inet dhcp' >> /etc/network/interfaces
|
||||||
|
|
||||||
echo 'network={' > $WIFI_CONFIG
|
echo 'network={' > $WIFI_CONFIG
|
||||||
echo " ssid=\"${ssid}\"" >> $WIFI_CONFIG
|
echo " ssid=\"${ssid}\"" >> $WIFI_CONFIG
|
||||||
echo ' key_mgmt=NONE' >> $WIFI_CONFIG
|
echo ' key_mgmt=NONE' >> $WIFI_CONFIG
|
||||||
echo '}' >> $WIFI_CONFIG
|
echo '}' >> $WIFI_CONFIG
|
||||||
|
|
||||||
systemctl restart network-manager
|
systemctl restart network-manager
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_networks_from_file {
|
function create_networks_from_file {
|
||||||
if [ ! -f $WIFI_FILE ]; then
|
if [ ! -f $WIFI_NETWORKS_FILE ]; then
|
||||||
return
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f /etc/network/interfaces_original ]; then
|
if [ ! -f /etc/network/interfaces_original ]; then
|
||||||
if ! grep -q "# wifi enabled" /etc/network/interfaces; then
|
if ! grep -q "# wifi enabled" /etc/network/interfaces; then
|
||||||
cp /etc/network/interfaces /etc/network/interfaces_original
|
cp /etc/network/interfaces /etc/network/interfaces_original
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '# wifi enabled' > /etc/network/interfaces
|
echo '# wifi enabled' > /etc/network/interfaces
|
||||||
echo 'auto lo' >> /etc/network/interfaces
|
echo 'auto lo' >> /etc/network/interfaces
|
||||||
echo 'iface lo inet loopback' >> /etc/network/interfaces
|
echo 'iface lo inet loopback' >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
echo 'allow-hotplug eth0' >> /etc/network/interfaces
|
||||||
echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
|
echo 'iface eth0 inet dhcp' >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo 'allow-hotplug wlan0' >> /etc/network/interfaces
|
echo 'allow-hotplug wlan0' >> /etc/network/interfaces
|
||||||
echo 'iface wlan0 inet manual' >> /etc/network/interfaces
|
echo 'iface wlan0 inet manual' >> /etc/network/interfaces
|
||||||
echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces
|
echo " wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces
|
||||||
echo '' >> /etc/network/interfaces
|
echo '' >> /etc/network/interfaces
|
||||||
echo 'iface default inet dhcp' >> /etc/network/interfaces
|
echo 'iface default inet dhcp' >> /etc/network/interfaces
|
||||||
|
|
||||||
# remove wpa_supplicant.conf if it exists
|
# remove wpa_supplicant.conf if it exists
|
||||||
if [ -f $WIFI_CONFIG ]; then
|
if [ -f $WIFI_CONFIG ]; then
|
||||||
rm -f $WIFI_CONFIG
|
rm -f $WIFI_CONFIG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ctr=0
|
ctr=0
|
||||||
while read -r line
|
while read -r line
|
||||||
do
|
do
|
||||||
if [ ${#line} -gt 1 ]; then
|
if [ ${#line} -gt 1 ]; then
|
||||||
if [[ "$line" != '#'* ]]; then
|
if [[ "$line" != '#'* ]]; then
|
||||||
if [ $ctr -eq 0 ]; then
|
if [ $ctr -eq 0 ]; then
|
||||||
WIFI_SSID="$line"
|
WIFI_SSID="$line"
|
||||||
fi
|
fi
|
||||||
if [ $ctr -eq 1 ]; then
|
if [ $ctr -eq 1 ]; then
|
||||||
WIFI_TYPE="$line"
|
WIFI_TYPE="$line"
|
||||||
if [[ $WIFI_TYPE == $'none' || $WIFI_TYPE == $'None' ]]; then
|
if [[ $WIFI_TYPE == $'none' || $WIFI_TYPE == $'None' ]]; then
|
||||||
echo 'network={' >> $WIFI_CONFIG
|
echo 'network={' >> $WIFI_CONFIG
|
||||||
echo " ssid=\"${WIFI_SSID}\"" >> $WIFI_CONFIG
|
echo " ssid=\"${WIFI_SSID}\"" >> $WIFI_CONFIG
|
||||||
echo ' key_mgmt=NONE' >> $WIFI_CONFIG
|
echo ' key_mgmt=NONE' >> $WIFI_CONFIG
|
||||||
echo '}' >> $WIFI_CONFIG
|
echo '}' >> $WIFI_CONFIG
|
||||||
ctr=0
|
ctr=0
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ $ctr -eq 2 ]; then
|
if [ $ctr -eq 2 ]; then
|
||||||
WIFI_PASSPHRASE="$line"
|
WIFI_PASSPHRASE="$line"
|
||||||
wpa_passphrase "$WIFI_SSID" "$WIFI_PASSPHRASE" >> $WIFI_CONFIG
|
wpa_passphrase "$WIFI_SSID" "$WIFI_PASSPHRASE" >> $WIFI_CONFIG
|
||||||
ctr=0
|
ctr=0
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ctr=$((ctr + 1))
|
ctr=$((ctr + 1))
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done < $WIFI_FILE
|
done < $WIFI_NETWORKS_FILE
|
||||||
|
|
||||||
systemctl restart network-manager
|
systemctl restart network-manager
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_help {
|
function show_help {
|
||||||
echo ''
|
echo ''
|
||||||
echo $"${PROJECT_NAME}-wifi -i [interface] -t [type] -s [ssid] -p [passphrase]"
|
echo $"${PROJECT_NAME}-wifi -i [interface] -t [type] -s [ssid] -p [passphrase]"
|
||||||
echo ''
|
echo ''
|
||||||
echo $'Wifi configuration tool'
|
echo $'Wifi configuration tool'
|
||||||
echo ''
|
echo ''
|
||||||
echo $' --help Show help'
|
echo $' --help Show help'
|
||||||
echo $' -i --interface [wlan0|wlan1...] Device name'
|
echo $' -i --interface [wlan0|wlan1...] Device name'
|
||||||
echo $' -t --type [wpa2-psk|none] Security type'
|
echo $' -t --type [wpa2-psk|none] Security type'
|
||||||
echo $' -s --ssid [id] Set SSID'
|
echo $' -s --ssid [id] Set SSID'
|
||||||
echo $' -p --passphrase [text] Set passphrase'
|
echo $' -p --passphrase [text] Set passphrase'
|
||||||
echo $' --hotspot [yes|no] Create a hotspot'
|
echo $' --hotspot [yes|no] Create a hotspot'
|
||||||
echo ''
|
echo ''
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
while [[ $# > 1 ]]
|
while [[ $# > 1 ]]
|
||||||
do
|
do
|
||||||
key="$1"
|
key="$1"
|
||||||
|
|
||||||
case $key in
|
case $key in
|
||||||
--help)
|
--help)
|
||||||
show_help
|
show_help
|
||||||
;;
|
;;
|
||||||
-i|--if|--interface)
|
-i|--if|--interface)
|
||||||
shift
|
shift
|
||||||
WIFI_INTERFACE=${1}
|
WIFI_INTERFACE=${1}
|
||||||
;;
|
;;
|
||||||
-t|--type)
|
-t|--type)
|
||||||
shift
|
shift
|
||||||
WIFI_TYPE=${1}
|
WIFI_TYPE=${1}
|
||||||
;;
|
;;
|
||||||
-s|--ssid)
|
-s|--ssid)
|
||||||
shift
|
shift
|
||||||
WIFI_SSID=${1}
|
WIFI_SSID=${1}
|
||||||
;;
|
;;
|
||||||
-p|--pass|--passphrase)
|
-p|--pass|--passphrase)
|
||||||
shift
|
shift
|
||||||
WIFI_PASSPHRASE=${1}
|
WIFI_PASSPHRASE=${1}
|
||||||
;;
|
;;
|
||||||
--hostpot)
|
--hostpot)
|
||||||
shift
|
shift
|
||||||
WIFI_HOTSPOT=${1}
|
WIFI_HOTSPOT=${1}
|
||||||
;;
|
;;
|
||||||
--config)
|
--networks)
|
||||||
shift
|
shift
|
||||||
WIFI_FILE=${1}
|
WIFI_NETWORKS_FILE=${1}
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
# unknown option
|
# unknown option
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -f $WIFI_FILE ]; then
|
if [ -f $WIFI_NETWORKS_FILE ]; then
|
||||||
create_networks_from_file
|
create_networks_from_file
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! $WIFI_SSID ]; then
|
if [ ! $WIFI_SSID ]; then
|
||||||
echo $'No SSID given'
|
echo $'No SSID given'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $WIFI_HOTSPOT != 'no' ]]; then
|
if [[ $WIFI_HOTSPOT != 'no' ]]; then
|
||||||
hotspot_on
|
hotspot_on
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
hotspot_off
|
hotspot_off
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $WIFI_TYPE != 'none' ]]; then
|
if [[ $WIFI_TYPE != 'none' ]]; then
|
||||||
if [ ! $WIFI_PASSPHRASE ]; then
|
if [ ! $WIFI_PASSPHRASE ]; then
|
||||||
echo $'No wifi passphrase was given'
|
echo $'No wifi passphrase was given'
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $WIFI_TYPE == 'wpa2-psk' ]]; then
|
if [[ $WIFI_TYPE == 'wpa2-psk' ]]; then
|
||||||
if [ ! -d /etc/wpa_supplicant ]; then
|
if [ ! -d /etc/wpa_supplicant ]; then
|
||||||
echo $'wpasupplicant package is not installed'
|
echo $'wpasupplicant package is not installed'
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
wifi_wpa2_psk "$WIFI_SSID" "$WIFI_PASSPHRASE"
|
wifi_wpa2_psk "$WIFI_SSID" "$WIFI_PASSPHRASE"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $WIFI_TYPE == 'none' ]]; then
|
if [[ $WIFI_TYPE == 'none' ]]; then
|
||||||
wifi_none "$WIFI_SSID"
|
wifi_none "$WIFI_SSID"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue