diff options
Diffstat (limited to 'src/dnsmasq-dhcp-script.sh')
-rw-r--r-- | src/dnsmasq-dhcp-script.sh | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/dnsmasq-dhcp-script.sh b/src/dnsmasq-dhcp-script.sh deleted file mode 100644 index 7469447..0000000 --- a/src/dnsmasq-dhcp-script.sh +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | #!/bin/sh | ||
2 | [ "$1" = tftp ] || exit 0 | ||
3 | . samizdat-paths.sh | ||
4 | TFTP_ROOT=${samizdat_isolinux_dir} | ||
5 | TFTP_FILE=$4 | ||
6 | TFTP_FILE_SIZE=$3 | ||
7 | CLIENT_IP=$3 | ||
8 | |||
9 | # dnsmasq clears the environment. kiki needs at least $HOME | ||
10 | export USER=root | ||
11 | export MAIL=/var/mail/root | ||
12 | export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
13 | export LANG=en_US.UTF-8 | ||
14 | export HOME=/root | ||
15 | export LANGUAGE=en_US:en | ||
16 | export LOGNAME=root | ||
17 | |||
18 | debug() | ||
19 | { | ||
20 | LOGDIR=/var/log/dnsmasq-dhcp-script | ||
21 | mkdir -p "$LOGDIR" | ||
22 | exec > "$LOGDIR/$$.log" 2>&1 | ||
23 | set -x | ||
24 | } | ||
25 | |||
26 | new_child() | ||
27 | { | ||
28 | child_dir=$samizdat_child_dir/child.$$ | ||
29 | if [ -d "$child_dir" ]; then | ||
30 | rmdir "$child_dir" || exit 1 | ||
31 | fi | ||
32 | |||
33 | sh -x "$(which keygen.sh)" "$child_dir" || return | ||
34 | tar --exclude '*~' -zcf "$child_dir"/gnupghome.tar -C "$child_dir"/root/.gnupg . || return | ||
35 | |||
36 | tftp_dir="${TFTP_ROOT}"/"$CLIENT_IP" | ||
37 | if [ ! -d "$tftp_dir" ]; then | ||
38 | ATOMIC=y | ||
39 | dest_dir="$tftp_dir"~ | ||
40 | |||
41 | # DNSMASQ DOCUMENTATION IS WRONG OMFG | ||
42 | # Otherwise this symlink farm would be unnecessary | ||
43 | |||
44 | mkdir -p "$dest_dir" | ||
45 | (cd "$dest_dir" && ln -sf ../* . && rm "$CLIENT_IP"~) || return | ||
46 | else | ||
47 | dest_dir="$tftp_dir" | ||
48 | fi | ||
49 | |||
50 | chown dnsmasq "$child_dir" "$child_dir"/gnupghome.tar | ||
51 | ln -sf "$child_dir"/gnupghome.tar "$dest_dir"/ | ||
52 | |||
53 | if [ "$ATOMIC" ]; then | ||
54 | mv -T "$dest_dir" "$tftp_dir" | ||
55 | fi | ||
56 | } | ||
57 | |||
58 | cleanup_after_fail() | ||
59 | { | ||
60 | umount "$child_dir" | ||
61 | rmdir "$child_dir" | ||
62 | } | ||
63 | |||
64 | exit_unless_needed() | ||
65 | { | ||
66 | |||
67 | case "$TFTP_FILE" in | ||
68 | "${TFTP_ROOT}/linux/vmlinuz") | ||
69 | ;; | ||
70 | "${TFTP_ROOT}/${CLIENT_IP}/linux/vmlinuz") | ||
71 | [ -e "${TFTP_ROOT}/${CLIENT_IP}/gnupghome.tar" ] && exit | ||
72 | ;; | ||
73 | *) exit | ||
74 | ;; | ||
75 | esac | ||
76 | } | ||
77 | |||
78 | exit_unless_needed | ||
79 | |||
80 | debug | ||
81 | |||
82 | (new_child || cleanup_after_fail) & | ||