--- /dev/null
+#!/bin/bash
+
+# chost: get canonical hostname
+
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
+host=$1
+addr=$(host $host)
+addr=${addr##* }
+h=$(host $addr)
+h=${h##* }
+echo ${h%%.*}
cd $(dirname $(readlink -f "$BASH_SOURCE"))
-faiserver_host=faiserver
# i use faiserver as a dns alias, but ssh key is associated with
# a canonical hostname and we will have ssh warning spam unless we
# use it, so look it up.
-if addr=$(host faiserver); then
- addr=${addr##* }
- if h=$(host $addr); then
- h=${h##* }
- faiserver_host=${h%%.*}
- else
- echo "$0: warning: host \$addr($addr) failed"
- fi
-else
- echo "$0: warning: host faiserver failed"
-fi
+faiserver_host=$(chost faiserver) || faiserver_host=faiserver
ssh root@$faiserver_host rm -rf /srv/fai/config
$ROOTCMD ln -sf $dir /root
$ROOTCMD ln -sf /q/p /
-chown -R 1000:1000 $dir
+$ROOTCMD chown -R 1000:1000 $dir
while true; do
$ROOTCMD chown 1000:1000 $dir
$ROOTCMD chmod 700 $dir
btrfs subvolume set-default 0 /mnt
[[ ! -e /mnt/root_$DISTRO ]] || btrfs subvolume delete /mnt/root_$DISTRO
-
## create subvols ##
cd /mnt
-for x in q home_$DISTRO root_$DISTRO; do
- btrfs subvolume list . | grep "$x$" >/dev/null || btrfs subvolume create $x
-done
+btrfs subvolume create root_$DISTRO
chown root:1000 q
-
mkdir -p /mnt/root_$DISTRO/boot
for x in root/a q/a; do
mkdir -p $x
$first_root_crypt / btrfs noatime,subvol=root_$DISTRO 0 0
$first_root_crypt /q btrfs noatime,subvol=q 0 0
/q/a /a none bind 0 0
-$first_root_crypt /home btrfs noatime,subvol=home_$DISTRO 0 0
$first_boot_dev /boot btrfs noatime,subvol=boot_$DISTRO 0 0
EOF
f=/target/home/ian/.ssh/authorized_keys
if [[ ! -L $f || -e $f ]]; then
fcopy -r -M /home/ian/.ssh
+else
+ echo "$0: info: $f exists"
fi
/var/lib/fai/config/distro-install-common/end
rm -rf /root/.ssh
cp -rL /home/ian/.ssh /root
chown -R root:root /root/.ssh
+chmod 700 /root/.ssh
# default jessie groups + kvm & systemd-journal
-usermod -aG cdrom,floppy,sudo,audio,dip,video,plugdev,netdev,kvm,systemd-journal ian
+usermod -aG cdrom,floppy,sudo,audio,dip,video,plugdev,netdev,systemd-journal ian
EOF
done
if ifclass frodo; then
- $ROOTCMD usermod -p "$(cat /var/lib/fai/config/distro-install-common/shadow/traci-simple)" traci
+ $ROOTCMD usermod -p "$(cat /var/lib/fai/config/distro-install-common/traci-simple)" traci
fi
--- /dev/null
+#!/bin/bash
+
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
+usage() {
+ cat <<EOF
+Usage: ${0##*/}
+Disable the fai nfs server.
+EOF
+ exit $1
+}
+
+if [[ $1 ]]; then
+ usage 1
+fi
+
+ssh root@$(chost faiserver) "sed -ri 's,^/srv/fai/,#\0,' /etc/exports; exportfs -ra"
--- /dev/null
+#!/bin/bash
+
+set -eE -o pipefail
+trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
+usage() {
+ cat <<EOF
+Usage: ${0##*/}
+Disable the fai nfs server.
+EOF
+ exit $1
+}
+
+if [[ $1 ]]; then
+ usage 1
+fi
+
+ssh root@$(chost faiserver) "sed -ri 's,^\s*#\s*(/srv/fai/.*),\1,' /etc/exports; exportfs -ra"
-#!/bin/bash -x
+#!/bin/bash
# Setup dhcp server to point to tftp server,
# and depending on the type, setup the tftp server.
-h|--help Print help and exit
-- Subsequent arguments are never treated as options
+-p Persist. Otherwise, wait for 2 dhcp acks then remove.
EOF
exit $1
}
##### begin command line parsing ########
-
+persist=false
args=()
while [[ $1 ]]; do
case $1 in
--) shift; break ;;
-h|--help) usage ;;
+ -p) persist=true; shift ;;
*) args+=("$1"); shift ;;
esac
done
host_tag="tag:$host,"
fi
+case $type in
+ :|true) persist=true ;;
+esac
+
##### end command line parsing ########
+sv() {
+ echo "$@"
+ "$@"
+}
+
arch() {
- plain
cat <<EOF
dhcp-option-force=209,boot/syslinux/archiso.cfg
dhcp-option-force=210,/arch/
# if arch was used before, this additionally needs
# the tftp link in /mnt/usb to be changed.
cat <<EOF
-enable-tftp
-tftp-root=/mnt/usb/tftpboot
dhcp-boot=${host_tag}pxelinux.0
EOF
}
EOF
}
-
-$type | ssh wrt "cedit pxe-server /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
+echo "setting config type: $type"
+$type | ssh wrt "cedit pxe-server /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart #
if [[ $type == arch ]]; then arch-pxe-mount; fi"
+
+
+if ! $persist; then
+ if [[ $host ]]; then
+ host_regex=" $host"
+ fi
+ regex=".*DHCPACK.*$host_regex$"
+ i=0
+ tmp=$(mktemp)
+ while (( i != 2 )) && read line; do
+ if [[ $line =~ $regex ]]; then
+ i=$((i+1))
+ echo $line
+ fi
+ done < <(ssh wrt logread -f)
+ sv sleep 5
+ sv "$BASH_SOURCE" :
+fi
# template
# dhcp-host=,192.168.1.,
+
+# Just leave the tftp server up even if we aren't doing pxe boot.
+# It has no sensitive info.
+enable-tftp
+tftp-root=/mnt/usb/tftpboot
EOF
if $dnsmasq_restart; then