My network is a wndr3700v2 router with openwrt on it and a few pcs
with various gnu/linux distros on them.
+
+
+Scripts meant to be called interactively:
+
+
+arch-init-remote # install arch (after it's been booted into it's setup env)
+fai-revm # test fai on a fresh vm
+faiserver-revm # create a vm which is a fai server
+faiserver-uninstall
+fresize # resize swap or boot partitions in a host created with my fai setup
+pxe-server # temporarily enable (usually) fai or arch boot server
+wrt-setup-remote # setup my router
cd $(dirname $(readlink -f "$BASH_SOURCE"))
-export hostname="$1"
+export HOSTNAME="$1"
mirror=$2
TPPASS="$(cat /root/shadow/traci-simple)"
}
export -f ifclass
classes= # used by fcopy
-for x in $(bash /a/bin/fai/config/class/50-host-classes); do
+for x in $(bash /a/bin/fai/fai/config/class/50-host-classes); do
# export class vars with CLASS_ in front to avoid name colissions.
classes+=" $x"
export CLASS_$x=true
classes="${classes# }"
export classes
export FAI_ROOT=/
-export FAI=/a/bin/fai/config
+export FAI=/a/bin/fai/fai/config
x2)
echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT" ;;
tp)
- echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT" ;;
+ echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT STABLE" ;;
frodo)
echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT" ;;
treetowl)
echo "FAIBASE DEBIAN DESKTOP PARTITION_PROMPT" ;;
+ lj)
+ echo "FAIBASE DEBIAN LINODESTABLE PARTITION_PROMPT" ;;
+ li)
+ echo "FAIBASE DEBIAN LINODESTABLE PARTITION_PROMPT" ;;
# faiserver)
# echo "FAIBASE DEBIAN DEMO FAISERVER" ;;
# xfcehost)
fi
### begin set hostname
-echo $hostname > /etc/hostname
+echo $HOSTNAME > /etc/hostname
sed -i '/^127\.0\.1\.1/d' /etc/hosts
-echo "127.0.1.1 $hostname" >> /etc/hosts
+echo "127.0.1.1 $HOSTNAME" >> /etc/hosts
hostname -F /etc/hostname
### end set hostname
pwfile=$2
if [[ $pwfile && -e $pwfile ]]; then
printf "$user:" | cat - "$pwfile" | $ROOTCMD chpasswd -e
- else
- echo "$0: warning: no pw set for $user"
+ else
+ echo "$0: warning: no pw set for $user"
fi
}
au() {
if ! $ROOTCMD getent passwd $1; then
- $ROOTCMD useradd -m $1 -s /bin/bash || [[ $? == 9 ]]
+ $ROOTCMD useradd -m -s /bin/bash $1 || [[ $? == 9 ]]
fi
}
-echo "IANNNNNNN 222222222, $ROOTPW"
-ls -la $ROOTPW
-
chpw root "$ROOTPW"
# 9 = user already exists. so we are idempotent.
au ian
dir=/q/p/c/machine_specific/$HOSTNAME/.unison
$ROOTCMD mkdir -p $dir
-$ROOTCMD rm -rf /root/.unison
-$ROOTCMD ln -sf $dir /root
$ROOTCMD ln -sf /q/p /
-
$ROOTCMD chown -R 1000:1000 $dir
while true; do
$ROOTCMD chown 1000:1000 $dir
--- /dev/null
+STABLE
\ No newline at end of file
--- /dev/null
+deb http://mirrors.linode.com/debian/ jessie main
+deb-src http://mirrors.linode.com/debian/ jessie main
+
+deb http://security.debian.org/ jessie/updates main
+deb-src http://security.debian.org/ jessie/updates main
+
+# jessie-updates, previously known as 'volatile'
+deb http://mirrors.linode.com/debian/ jessie-updates main
+deb-src http://mirrors.linode.com/debian/ jessie-updates main
chmod +x $f
-if ifclass tp; then
- d=$target/q/root/shadow
- mkdir -p $d
- # ls -la /var/lib/fai/config/distro-install-common
- cp /var/lib/fai/config/distro-install-common/traci{,-simple} $d
- chmod -R o-rwx $d
+if ifclass demohost; then
+ files=(/var/lib/fai/config/distro-install-common/luks/host-demohost)
+elif ifclass tp; then
+ files=(/var/lib/fai/config/distro-install-common/luks/host-{tp,demohost})
+fi
+if [[ ${files[0]} ]]; then
d=$target/q/root/luks
mkdir -p $d
- cp /var/lib/fai/config/distro-install-common/luks/host-{tp,demohost} $d
+ cp ${files[@]} $d
chmod -R o-rwx $d
fi
exit 1
fi
+if ! type -t fcopy &>/dev/null; then
+ sudo apt-get -y install fai-client
+fi
dir=/q/root/shadow
-if [[ ! -e $dir ]]; then
+fai_shadow=$FAI/distro-install-common/shadow
+if [[ ! -e $dir && -e $fai_shadow ]]; then
mkdir -p $dir
- echo "IANNNNNN 111"
- ls -la $FAI/distro-install-common/shadow
- mount -o bind $FAI/distro-install-common/shadow $dir
+ mount -o bind $fai_shadow $dir
fi
$FAI/distro-install-common/end
-if ifclass STABLE; then
+if ifclass STABLE || ifclass LINODESTABLE; then
fcopy -M /etc/apt/preferences
fi
if ifclass DEBIAN; then
fcopy -M /etc/apt/preferences.d/unstable
fcopy -riM /etc/apt/sources.list.d
+ $ROOTCMD apt-get update
fi
# note:
# fcopy -i = ignore nonmatching class error, always return 0.
-f=$FAI_ROOT/home/ian/.ssh/authorized_keys
-if [[ ! -L $f || -e $f ]]; then
- fcopy -r -M /home/ian/.ssh
-else
- echo "$0: info: $f exists"
-fi
+# for lj, this will be empty and fail
+fcopy -riM /home/ian/.ssh
rm -f $FAI_ROOT/etc/apt/sources.list
chroot $FAI_ROOT bash <<'EOF'
set -eE -o pipefail
+mkdir -p /home/ian/.ssh
+f=/root/.ssh/authorized_keys
+if [[ -e $f ]]; then
+ cp $f /home/ian/.ssh
+fi
chown -R 1000:1000 /home/ian/.ssh
chmod -R u=Xrw,og= /home/ian/.ssh
rm -rf /root/.ssh
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,systemd-journal ian
+# default jessie groups + kvm, systemd-journal, adm
+usermod -aG adm,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev,systemd-journal ian
EOF
#!/bin/bash -l
+# create a vm which is a fai server
set -x
set -eE -o pipefail
-h|--help Print help and exit
-- Subsequent arguments are never treated as options
-p Persist. Otherwise, wait for 2 dhcp acks then remove.
+-r Don't redeploy fai config.
EOF
exit $1
}
persist=false
args=()
-redep=false
+redep=true
while [[ $1 ]]; do
case $1 in
--) shift; break ;;
-h|--help) usage ;;
- -r) redep=true; shift ;;
+ -r) redep=false; shift ;;
-p) persist=true; shift ;;
*) args+=("$1"); shift ;;
esac
EOF
}
-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 $redep && [[ $type == fai ]]; then
- fai-redep
-fi
-if ! $persist; then
- echo "waiting for 2 dhcp acks then disabling pxe"
+ack-wait() {
+ wait_count=$1
if [[ $host ]]; then
host_regex=" $host"
fi
regex=".*DHCPACK.*$host_regex$"
i=0
tmp=$(mktemp)
- while (( i != 2 )) && read line; do
+ while (( i != wait_count )) && read line; do
if [[ $line =~ $regex ]]; then
i=$((i+1))
echo $line
fi
done < <(ssh wrt logread -f)
sv sleep 5
- sv "$BASH_SOURCE" :
+}
+
+set-pxe() {
+ ${1:-$type} | ssh wrt "cedit pxe-server /etc/dnsmasq.conf || /etc/init.d/dnsmasq restart
+if [[ $type == arch ]]; then arch-pxe-mount; fi"
+}
+
+set-pxe
+
+if [[ $type == fai ]]; then
+ if $redep; then
+ fai-redep
+ fi
+ faiserver-enable
+fi
+
+if ! $persist; then
+ echo "waiting for 2 dhcp acks then disabling pxe"
+ ack-wait 2
+ set-pxe :
+ if [[ $type == fai ]]; then
+ # fai server can contain sensitive info, so turn it off
+ # when it's not in use.
+ echo "waiting for 1 dhcp ack then disabling fai server"
+ ack-wait 1
+ faiserver-disable
+ fi
fi
192.168.1.6 testvm
192.168.1.8 tp
72.14.176.105 li
-173.255.198.166 lj
+173.255.202.210 lj
+23.239.31.172 lk
EOF
# in a browsing session, I probably won't ever do 5000 lookups
# before the ttl expiration or whatever does expiration.
cache-size=10000
+# ask all servers, use the one which responds first.
# http://ma.ttwagner.com/make-dns-fly-with-dnsmasq-all-servers/
all-servers
-# namebench showed 4 servers fairly close ranking:
+# namebench showed 4 servers fairly close ranking.
# qwest
-server=205.171.3.65
-server=205.171.2.25
+#server=205.171.3.65
+#server=205.171.2.25
# clearwire anchorage
-server=64.13.115.12
+#server=64.13.115.12
# comcast spokane
-server=68.87.69.146
+#server=68.87.69.146
# google
server=8.8.4.4
+server=8.8.8.8
# NTT
-server=129.250.35.250
+#server=129.250.35.250
# isp servers
-server=75.75.76.76
-server=75.75.75.75
+#server=75.75.76.76
+#server=75.75.75.75
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
h=root@192.168.1.1
-scp /a/bin/fai/wrt-setup /a/bin/bash-programs-by-ian/repos/cedit/cedit $h:/usr/bin
+scp /a/bin/fai/wrt-setup /a/bin/cedit/cedit $h:/usr/bin
ssh $h <<'EOF'
if ! opkg list-installed|grep bash; then
opkg update