summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortorben2018-09-06 21:48:24 +0200
committertorben2018-09-06 21:48:24 +0200
commit52a44e3bb2ce8bbf5d26eb7a8d27636607ba21bc (patch)
tree703cd1570047639146aeac51eccfe517c7f0d36a
parentrefactoring. (diff)
downloadsystemd-init-52a44e3bb2ce8bbf5d26eb7a8d27636607ba21bc.tar.gz
systemd-init-52a44e3bb2ce8bbf5d26eb7a8d27636607ba21bc.tar.xz
systemd-init-52a44e3bb2ce8bbf5d26eb7a8d27636607ba21bc.zip
Update bashlunk and fix many bugs.
m---------modules.d/bashlink/bashlink0
-rwxr-xr-xmodules.d/dnbd-root-filesystem/hooks/prepare-root-filesystem.sh6
-rwxr-xr-xmodules.d/dnbd-root-filesystem/hooks/update-boot-files.sh56
-rwxr-xr-xmodules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh1
-rwxr-xr-xmodules.d/systemd-networkd-ext/hooks/prepare-network-service-in-newroot.sh15
-rwxr-xr-xmodules.d/systemd-networkd-ext/module-setup.sh12
6 files changed, 65 insertions, 25 deletions
diff --git a/modules.d/bashlink/bashlink b/modules.d/bashlink/bashlink
-Subproject 2caff2b62cdd2a02d1b97f1343179691c8f1ef7
+Subproject f58419ea8d7ba2717ef9a93adeeb9a624fbdbf8
diff --git a/modules.d/dnbd-root-filesystem/hooks/prepare-root-filesystem.sh b/modules.d/dnbd-root-filesystem/hooks/prepare-root-filesystem.sh
index 8dae12dd..b20267e7 100755
--- a/modules.d/dnbd-root-filesystem/hooks/prepare-root-filesystem.sh
+++ b/modules.d/dnbd-root-filesystem/hooks/prepare-root-filesystem.sh
@@ -142,19 +142,19 @@ bl.exception.try {
bl.logging.info Activating persistent mode.
local persistent_mountpoint=/mnt/slx_writable_device
mkdir --parents "$persistent_mountpoint"
- if ! mount --type auto "$persistent_device" "$persistent_mountpoint"; then
+ if ! mount "$persistent_device" "$persistent_mountpoint"; then
bl.logging.warn \
Failed to mount $persistent_device, checking filesystem.
! $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CHECK_COMMAND \
"$persistent_device"
- if ! mount --type auto "$persistent_device" "$persistent_mountpoint"; then
+ if ! mount "$persistent_device" "$persistent_mountpoint"; then
bl.logging.warn \
Mounting $persistent_device, still failing. Creating new \
filesystem on device.
$SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CREATE_COMMAND \
"$persistent_device"
fi
- if ! mount --type auto "$persistent_device" "$persistent_mountpoint"; then
+ if ! mount "$persistent_device" "$persistent_mountpoint"; then
bl.logging.warn \
Mounting $persistent_device, still failing, giving up, \
and using in ram storage.
diff --git a/modules.d/dnbd-root-filesystem/hooks/update-boot-files.sh b/modules.d/dnbd-root-filesystem/hooks/update-boot-files.sh
index 63d09bd0..e8003b8d 100755
--- a/modules.d/dnbd-root-filesystem/hooks/update-boot-files.sh
+++ b/modules.d/dnbd-root-filesystem/hooks/update-boot-files.sh
@@ -45,11 +45,11 @@ bl.exception.try {
umount /mnt
fi
done <<< "$(lsblk --list --noheadings --output NAME)"
- local -i kernel_version=0
+ local -i kernel_version=-1
if [ -f /mnt/kernel-version ]; then
kernel_version=$(cat /mnt/kernel-version)
fi
- local -i initramfs_version=0
+ local -i initramfs_version=-1
if [ -f /mnt/initramfs-version ]; then
initramfs_version=$(cat /mnt/initramfs-version)
fi
@@ -129,6 +129,29 @@ bl.exception.try {
--extended-regexp \
--only-matching \
'^[^ ]+')"
+ if mount "$device_partition_path" /mnt &>/dev/null; then
+ umount /mnt
+ else
+ bl.logging.warn \
+ Failed to mount $device_partition_path, checking filesystem.
+ ! $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CHECK_COMMAND \
+ "$device_partition_path"
+ if mount "$device_partition_path" /mnt &>/dev/null; then
+ umount /mnt
+ else
+ bl.logging.warn \
+ Mounting $device_partition_path, still failing. Creating new \
+ filesystem on device.
+ $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CREATE_COMMAND \
+ "$device_partition_path"
+ if mount "$device_partition_path" /mnt &>/dev/null; then
+ umount /mnt
+ else
+ bl.logging.warn \
+ Mounting $device_partition_path, still failing, giving up.
+ fi
+ fi
+ fi
fi
if mount "$device_partition_path" /mnt &>/dev/null; then
if [ -d /mnt/syslinux ]; then
@@ -193,7 +216,7 @@ DEFAULT arch
LABEL arch
LINUX ../$kernel_file_path
- APPEND $(cat /proc/cmdline)
+ APPEND $(cat /proc/cmdline | sed s/ WIRELESS_BOOTIF=false//)
INITRD ../$initramfs_file_path
EOF
boot_partition_mounted=true
@@ -305,20 +328,25 @@ EOF
\"$slx_server_base/initramfs\(-version\)\".
fi
if \
- (( kernel_version < new_kernel_version )) || \
- (( initramfs_version < new_initramfs_version ))
+ (( kernel_version != -1 )) || \
+ (( initramfs_version != -1 ))
then
if \
- kexec \
- --load "/mnt/$kernel_file_path" \
- --initrd "/mnt/$initramfs_file_path" \
- --reuse-cmdline
+ (( kernel_version < new_kernel_version )) || \
+ (( initramfs_version < new_initramfs_version ))
then
- umount /mnt
- kexec -e
- else
- bl.logging.warn \
- Failed to hot reload newer kernel and/or initramfs.
+ if \
+ kexec \
+ --load "/mnt/$kernel_file_path" \
+ --initrd "/mnt/$initramfs_file_path" \
+ --reuse-cmdline
+ then
+ umount /mnt
+ kexec -e
+ else
+ bl.logging.warn \
+ Failed to hot reload newer kernel and/or initramfs.
+ fi
fi
fi
fi
diff --git a/modules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh b/modules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh
index 722127d4..dd5d76f7 100755
--- a/modules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh
+++ b/modules.d/systemd-networkd-ext/hooks/convert-kcl-network-configuration-to-systemd-service-files.sh
@@ -333,6 +333,7 @@ if [[ "$WIRELESS_BOOTIF" != false ]]; then
echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="'$WIRELESS_BOOTIF'", NAME="'$WIRELESS_BOOTIF_NAME'"' \
> /etc/udev/rules.d/70-pxe-wireless-boot-interface.rules
fi
+ macchanger --random "$WIRELESS_BOOTIF_NAME"
fi
# Generate config files for networkd
diff --git a/modules.d/systemd-networkd-ext/hooks/prepare-network-service-in-newroot.sh b/modules.d/systemd-networkd-ext/hooks/prepare-network-service-in-newroot.sh
index f04cee06..a853e7ef 100755
--- a/modules.d/systemd-networkd-ext/hooks/prepare-network-service-in-newroot.sh
+++ b/modules.d/systemd-networkd-ext/hooks/prepare-network-service-in-newroot.sh
@@ -61,11 +61,13 @@ if $SLX_ONLINE; then
bl.logging.info \
Link service "$service_file_path" to \
"$NEWROOT_SYSINIT_TARGET_DIR/$service_name".
- ln \
- --force \
- --symbolic \
- "$service_file_path" \
- "$NEWROOT_SYSINIT_TARGET_DIR/$service_name"
+ if [[ "$service_name" != 'systemd-networkd.service' ]]; then
+ ln \
+ --force \
+ --symbolic \
+ "$service_file_path" \
+ "$NEWROOT_SYSINIT_TARGET_DIR/$service_name"
+ fi
done
if [[ "$SLX_WIRELESS_MAC" != false ]]; then
service_name=wpa_supplicant@wireless.service
@@ -96,7 +98,8 @@ if $SLX_ONLINE; then
# ../restart-wireless-daemon.service \
# "$NEWROOT/usr/lib/systemd/system/multi-user.target.wants/restart-wireless-daemon.service"
# Login to tty1 version, works:
- echo -e "[ ! -f /tmp/wireless-daemon-restarted ] && systemctl start restart-wireless-daemon.service && touch /tmp/wireless-daemon-restarted\n$(cat "$NEWROOT/root/.bash_profile")" \
+ # TODO remove "false" if working and dynamically add relevant mac address.
+ echo -e "false && [ ! -f /tmp/wireless-daemon-restarted ] && /run/initramfs/usr/bin/aireplay-ng --deauth 10 -a 18:0F:76:04:53:B1 wireless && sed --in-place --regexp-extended 's/(CriticalConnection=true)/#\1/' /etc/systemd/network/wireless.network && systemctl daemon-reload && systemctl start restart-wireless-daemon.service && touch /tmp/wireless-daemon-restarted\n$(cat "$NEWROOT/root/.bash_profile")" \
> "$NEWROOT/root/.bash_profile"
# Stops daemon at boot yet.
#bl.logging.info \
diff --git a/modules.d/systemd-networkd-ext/module-setup.sh b/modules.d/systemd-networkd-ext/module-setup.sh
index 255d8ad5..adee922d 100755
--- a/modules.d/systemd-networkd-ext/module-setup.sh
+++ b/modules.d/systemd-networkd-ext/module-setup.sh
@@ -191,6 +191,10 @@ install() {
# wpa_supplicant version:
inst_multiple -o \
$systemdsystemunitdir/wpa_supplicant@.service \
+ aireplay-ng \
+ wpa_cli \
+ dhclient \
+ macchanger \
wpa_supplicant
# optional:
#inst_multiple -o \
@@ -359,7 +363,7 @@ EOF
# overwritten.
[[ "$path" != /usr/lib/systemd/system/wpa_supplicant@.service ]] && \
# NOTE: We can ignore man-pages to run processes.
- [[ "$path" != /usr/share/man/* ]] && \regionendregion
+ [[ "$path" != /usr/share/man/* ]] && \
# NOTE: These files are necessary to let systemd distinguish
# between the initramfs and final system environment.
[[ "$path" != /etc/os-release ]] && \
@@ -375,7 +379,7 @@ EOF
if \\
[[ "\$SLX_WIRELESS_MAC" != false ]] && [[
\$SLX_WRITABLE_DEVICE_REMOVE_CACHE || \\
- ! -f /mnt/slx_writable_device/booted_to_wlan
+ ! -f /mnt/slx_writable_device/wlan_daemon_precached
]]
then
for path in "\${file_paths[@]}"; do
@@ -394,9 +398,13 @@ then
bl.logging.warn File \\"\$path\\" not available for pre-caching.
fi
done
+ # Needed to perform to inform the authentication server about
+ # deauthenticating the passed connection coming from the initramfs.
+ cp --force /usr/lib/libaircrack* "\$NEWROOT/usr/lib"
# NOTE: This would allow to traverse the full root target tree in offline
# mode:
#tree "\$NEWROOT" 1>/dev/null
+ touch /mnt/slx_writable_device/wlan_daemon_precached
fi
EOF
) > "$temporary_hook_file_path"