-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to work with Debian 12 bookworm
- Loading branch information
Showing
5 changed files
with
44 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,18 +57,16 @@ RUN debconf-set-selections <<EOF | |
$(cat files/debconf) | ||
EOF | ||
|
||
INSTALL files/wlan0 /etc/network/interfaces.d/wlan0 | ||
RUN systemctl restart networking | ||
|
||
INSTALL files/dnsmasq_hotspot.conf /etc/dnsmasq.d/hotspot.conf | ||
INSTALL files/hostapd.conf /etc/hostapd/hostapd.conf | ||
INSTALL files/hostapd_5ghz.conf /etc/hostapd/hostapd_5ghz.conf | ||
|
||
INSTALL 644 files/99-usb.rules /etc/udev/rules.d/99-usb.rules | ||
INSTALL 755 files/usb-mount.sh /usr/local/bin/usb-mount.sh | ||
INSTALL files/[email protected] /etc/systemd/system/[email protected] | ||
|
||
RUN tee /etc/dhcpcd.conf <<EOF | ||
interface wlan0 | ||
static ip_address=10.10.10.10/24 | ||
nohook resolv.conf, wpa_supplicant | ||
EOF | ||
INSTALL 755 files/[email protected] /etc/systemd/system/[email protected] | ||
|
||
RUN tee /etc/default/hostapd <<EOF | ||
DAEMON_CONF="/etc/hostapd/hostapd.conf" | ||
|
@@ -78,11 +76,6 @@ RUN tee /etc/default/dnsmasq <<EOF | |
DNSMASQ_EXCEPT=lo | ||
EOF | ||
|
||
RUN tee /etc/udev/rules.d/99-local.rules <<EOF | ||
KERNEL=="sd[a-z]*[0-9]", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/bin/systemctl start usb-mount@%k.service" | ||
KERNEL=="sd[a-z]*[0-9]", SUBSYSTEMS=="usb", ACTION=="remove", RUN+="/bin/systemctl stop usb-mount@%k.service" | ||
EOF | ||
|
||
RUN rm /etc/nginx/sites-enabled/default | ||
|
||
RUN systemctl enable hostapd | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd[a-z][0-9]", ENV{ID_FS_TYPE}!="", ENV{SYSTEMD_WANTS}="usb-mount@%k.service" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,34 @@ | ||
#!/usr/bin/env bash | ||
# If you are executing this script in cron with a restricted environment, | ||
# modify the shebang to specify appropriate path; /bin/bash in most distros. | ||
# And, also if you aren't comfortable using(abuse?) env command. | ||
#!/bin/bash | ||
|
||
# This script is based on https://serverfault.com/a/767079 posted | ||
# by Mike Blackwell, modified to our needs. Credits to the author. | ||
DEVICE="/dev/$1" | ||
|
||
# This script is called from systemd unit file to mount or unmount | ||
# a USB drive. | ||
MOUNT_OPTS="" | ||
FS_UID_GID="vfat exfat ntfs fuseblk" | ||
|
||
PATH="$PATH:/usr/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/bin:/sbin" | ||
log="logger -t usb-mount.sh -s " | ||
|
||
usage() | ||
{ | ||
${log} "Usage: $0 {add|remove} device_name (e.g. sdb1)" | ||
# Get filesystem type | ||
FSTYPE=$(blkid -o value -s TYPE "$DEVICE") | ||
if [ -z "$FSTYPE" ]; then | ||
logger "usb-mount: No filesystem type found for $DEVICE" | ||
exit 1 | ||
} | ||
|
||
if [[ $# -ne 2 ]]; then | ||
usage | ||
fi | ||
|
||
ACTION=$1 | ||
DEVBASE=$2 | ||
DEVICE="/dev/${DEVBASE}" | ||
|
||
# See if this drive is already mounted, and if so where | ||
MOUNT_POINT=$(mount | grep ${DEVICE} | awk '{ print $3 }') | ||
|
||
DEV_LABEL="" | ||
|
||
do_mount() | ||
{ | ||
if [[ -n ${MOUNT_POINT} ]]; then | ||
${log} "Warning: ${DEVICE} is already mounted at ${MOUNT_POINT}" | ||
exit 1 | ||
fi | ||
|
||
# Get info for this drive: $ID_FS_LABEL and $ID_FS_TYPE | ||
eval $(blkid -o udev ${DEVICE} | grep -i -e "ID_FS_LABEL" -e "ID_FS_TYPE") | ||
|
||
# Figure out a mount point to use | ||
LABEL=${ID_FS_LABEL} | ||
if grep -q " /media/${LABEL} " /etc/mtab; then | ||
# Already in use, make a unique one | ||
LABEL+="-${DEVBASE}" | ||
fi | ||
DEV_LABEL="${LABEL}" | ||
|
||
# Use the device name in case the drive doesn't have label | ||
if [ -z ${DEV_LABEL} ]; then | ||
DEV_LABEL="${DEVBASE}" | ||
fi | ||
|
||
MOUNT_POINT="/media/${DEV_LABEL}" | ||
|
||
${log} "Mount point: ${MOUNT_POINT}" | ||
|
||
mkdir -p ${MOUNT_POINT} | ||
|
||
# Global mount options | ||
OPTS="rw,relatime" | ||
|
||
# File system type specific mount options | ||
if [[ ${ID_FS_TYPE} == "vfat" ]]; then | ||
OPTS+=",users,gid=100,umask=000,shortname=mixed,utf8=1,flush" | ||
fi | ||
|
||
if ! mount -o ${OPTS} ${DEVICE} ${MOUNT_POINT}; then | ||
${log} "Error mounting ${DEVICE} (status = $?)" | ||
rmdir "${MOUNT_POINT}" | ||
exit 1 | ||
else | ||
# Track the mounted drives | ||
echo "${MOUNT_POINT}:${DEVBASE}" | cat >> "/var/log/usb-mount.track" | ||
fi | ||
|
||
${log} "Mounted ${DEVICE} at ${MOUNT_POINT}" | ||
} | ||
|
||
do_unmount() | ||
{ | ||
if [[ -z ${MOUNT_POINT} ]]; then | ||
${log} "Warning: ${DEVICE} is not mounted" | ||
else | ||
umount -l ${DEVICE} | ||
${log} "Unmounted ${DEVICE} from ${MOUNT_POINT}" | ||
/bin/rmdir "${MOUNT_POINT}" | ||
sed -i.bak "\@${MOUNT_POINT}@d" /var/log/usb-mount.track | ||
fi | ||
|
||
# Get label or use device name | ||
LABEL=$(blkid -o value -s LABEL "$DEVICE") | ||
if [ -z "$LABEL" ]; then | ||
LABEL=$(basename "$DEVICE") | ||
fi | ||
|
||
} | ||
MOUNT_POINT="/media/usb/$LABEL" | ||
if echo "$FS_UID_GID" | grep -qw "$FSTYPE"; then | ||
MOUNT_OPTS="-o uid=1000,gid=1000" | ||
fi | ||
|
||
case "${ACTION}" in | ||
add) | ||
do_mount | ||
;; | ||
remove) | ||
do_unmount | ||
;; | ||
*) | ||
usage | ||
;; | ||
esac | ||
mkdir -p "$MOUNT_POINT" | ||
mount $MOUNT_OPTS "$DEVICE" "$MOUNT_POINT" | ||
if [ $? -eq 0 ]; then | ||
#chown -R 1000:1000 "$MOUNT_POINT" | ||
logger "usb-mount: Mounted $DEVICE at $MOUNT_POINT" | ||
else | ||
logger "usb-mount: Failed to mount $DEVICE" | ||
rmdir "$MOUNT_POINT" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
[Unit] | ||
Description=Mount USB Drive on %i | ||
Description=Mount USB Device | ||
After=dev-%i.device | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=true | ||
ExecStart=/usr/local/bin/usb-mount.sh add %i | ||
ExecStop=/usr/local/bin/usb-mount.sh remove %i | ||
ExecStart=/usr/local/bin/usb-mount.sh %I | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
allow-hotplug wlan0 | ||
iface wlan0 inet static | ||
address 10.10.10.10 | ||
netmask 255.255.255.0 |