diff options
author | Andreas | 2019-07-24 19:56:57 +0200 |
---|---|---|
committer | Andreas | 2019-07-24 19:56:57 +0200 |
commit | c28673eb9d6cfb1a52bad8d23eb8f2b3408add9d (patch) | |
tree | bdf9a3aff1ed1be92a457840a913a334e63df078 | |
download | aur-c28673eb9d6cfb1a52bad8d23eb8f2b3408add9d.tar.gz |
initial version
-rw-r--r-- | .SRCINFO | 19 | ||||
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | PKGBUILD | 22 | ||||
-rw-r--r-- | mkinitcpio-wifi.install | 6 | ||||
-rw-r--r-- | wifi.hook | 31 | ||||
-rw-r--r-- | wifi.install | 65 |
6 files changed, 146 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..381b3d5fdf81 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,19 @@ +pkgbase = mkinitcpio-wifi + pkgdesc = mkinitcpio hook to enable wifi remote access + pkgver = 0.1 + pkgrel = 1 + url = https://aur.archlinux.org/packages/mkinitcpio-wifi/ + install = mkinitcpio-wifi.install + arch = any + license = GPL + depends = mkinitcpio + depends = wpa_supplicant + depends = iproute2 + optdepends = mkinitcpio-netconf + source = wifi.hook + source = wifi.install + sha256sums = d09c82d7b2756166b951de66d36094e4f03dfd5cd961cc1fa0852e119d09c828 + sha256sums = 325fd5aecf747549559eafa243be023c00276ca3c429c3d1222101f2075b7768 + +pkgname = mkinitcpio-wifi + diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..511c79207879 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.pkg.tar.* +src +pkg diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..9785edabb55b --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,22 @@ +# Maintainer: tequa +pkgname=mkinitcpio-wifi +pkgver=0.1 +pkgrel=1 +pkgdesc="mkinitcpio hook to enable wifi remote access" +arch=(any) +license=('GPL') +url="https://aur.archlinux.org/packages/mkinitcpio-wifi/" +depends=(mkinitcpio wpa_supplicant iproute2) +optdepends=(mkinitcpio-netconf) +install="mkinitcpio-wifi.install" +source=('wifi.hook' + 'wifi.install') +sha256sums=('d09c82d7b2756166b951de66d36094e4f03dfd5cd961cc1fa0852e119d09c828' + '325fd5aecf747549559eafa243be023c00276ca3c429c3d1222101f2075b7768') + +package() { + install -Dm 644 wifi.hook \ + "${pkgdir}/usr/lib/initcpio/hooks/wifi" + install -Dm 644 wifi.install \ + "${pkgdir}/usr/lib/initcpio/install/wifi" +} diff --git a/mkinitcpio-wifi.install b/mkinitcpio-wifi.install new file mode 100644 index 000000000000..ff4cf2a9cab0 --- /dev/null +++ b/mkinitcpio-wifi.install @@ -0,0 +1,6 @@ +post_install() { + echo 'to use this hook add "wifi" to your mkinitcpio.conf and create a' + echo 'wpa_supplicant configuration in /etc/wpa_supplicant/initcpio.conf, e.g.:' + echo 'wpa_passphrase "ESSID" "passphrase" > /etc/wpa_supplicant/initcpio.conf' + echo 'and rerun mkinitcpio' +} diff --git a/wifi.hook b/wifi.hook new file mode 100644 index 000000000000..2813af145793 --- /dev/null +++ b/wifi.hook @@ -0,0 +1,31 @@ +#!/usr/bin/ash + +run_hook () +{ + # sleep a couple of seconds so wlan0 is setup by kernel + sleep 3 + + echo "Starting wifi" + + # set wlan0 to up + ip link set wlan0 up + + # assocciate with wifi network + wpa_supplicant -B -D nl80211,wext -i wlan0 -c /etc/wpa_supplicant/initcpio.conf + + # sleep a couple of seconds so that wpa_supplicant finishes connecting + sleep 5 + + # wlan0 should now be connected and ready to be assigned an ip by the net hook +} + +run_cleanuphook () +{ + # kill wpa_supplicant running in the background + killall wpa_supplicant + + # set wlan0 link down + ip link set wlan0 down + + # wlan0 should now be fully disconnected from the wifi network +} diff --git a/wifi.install b/wifi.install new file mode 100644 index 000000000000..ba299cd24a79 --- /dev/null +++ b/wifi.install @@ -0,0 +1,65 @@ +#!/bin/bash + +get_mods_depending_on () { + local res + + res=$(lsmod | grep -e "^\\<${1}\\>" | awk '{print $4}') + res=(${res//,/ }) + + (( ${#res[*]} )) && printf "%s\n" "${res[@]}" +} + +get_mods_depending_on_recursive () { + local mods queue i_mod i_testmod + + mods=($1 $(get_mods_depending_on $1)) + queue=(${mods[@]}) + + while (( ${#queue[*]} )) ; do + i_mod=${queue[${#queue[@]}-1]} + unset queue[${#queue[@]}-1] + + for i_testmod in $(get_mods_depending_on ${i_mod}) ; do + in_array ${i_testmod} ${mods[@]} + if [ $? != 0 ] ; then + mods[${#mods[*]}]=${i_testmod} + queue[${#queue[*]}]=${i_testmod} + fi + done + done + + (( ${#mods[*]} )) && printf "%s\n" "${mods[@]}" +} + + +build () +{ + # Are we even needed? + if [ ! -r "/etc/wpa_supplicant/initcpio.conf" ]; then + echo "There is no wifi config /etc/wpa_supplicant/initcpio.conf; (create and rerun?); exit" + return 0 + fi + + # wireless modules + add_checked_modules "/drivers/net/wireless/" + + # make sure loaded modules depending on cfg80211 are included (e.g. iwlmvm) + local mod + for mod in $(get_mods_depending_on_recursive cfg80211) ; do + add_module $mod + done + + add_binary "killall" + add_binary "wpa_supplicant" + add_binary "ip" + add_runscript + + add_file "/etc/wpa_supplicant/initcpio.conf" "/etc/wpa_supplicant/initcpio.conf" +} + +help () +{ +cat<<HELPEOF + Enables wifi on boot, for ssh unlocking of disk. +HELPEOF +} |