#!/bin/bash -x
# Set grub to boot into a different distro, and reboot unless -r
-# $0 DISTRO_NAME
+# $0 [DISTRO_NAME]
+# with no argument, print available distros
# DISTRO_NAME is based on the partition names in /boot. eg boot_debianjessie
###### end command line parsing #####
+if [[ ! $distro ]]; then
+ echo "available distros:"
+ btrfs subvolume list /boot | sed -rn 's/^.*boot_(.*)/\1/p'
+ exit 0
+fi
+
if ! btrfs subvolume list /boot | grep "_$distro$" &>/dev/null; then
echo "$0: error: _$distro$ not found in btrfs subvolume list /boot:"
btrfs subvolume list /boot
dir=/q/p/c/machine_specific/$HOSTNAME/.unison
$ROOTCMD mkdir -p $dir
-$ROOTCMD chown 1000:1000 $dir
+
$ROOTCMD rm -rf /root/.unison
$ROOTCMD ln -s $dir /root
$ROOTCMD ln -s /q/p /
+while true; do
+ $ROOTCMD chown 1000:1000 $dir
+ $ROOTCMD chmod 660 $dir
+ dir=$(dirname $dir)
+ [[ $dir != /q ]] || break
+done
+
# kvm is normally created by some package,
# but unison doesn't like unknown groups, so make it now so initial sync works.
$ROOTCMD groupadd kvm
--- /dev/null
+Explanation: https://debian-handbook.info/browse/stable/sect.apt-get.html#sect.apt.priorities
+Explanation: And man apt_preferences
+Explanation: Installed packages get 100 priority, so this won't upgrade testing
+Explanation: packages unless explicitly asked to. Just went middlish between 1-100
+Explanation: Install with apt-get install package/testing. But if dependencies are
+Explanation: needed, or need upgrading,
+Explanation: apt-get -t testing package, setting testing to priority
+Explanation: 990 just for that command.
+Explanation: Use apt-cache policy to verify these settings.
+Package: *
+Pin: release a=unstable
+Pin-Priority: 30
+
+Package: *
+Pin: release a=unstable-updates
+Pin-Priority: 30
+
+
+Explanation: Allow this testing package to automatically upgrade.
+Package: unison
+Pin-Piority: 100
-Explanation: https://debian-handbook.info/browse/stable/sect.apt-get.html#sect.apt.priorities
-Explanation: And man apt_preferences
-Explanation: Installed packages get 100 priority, so this won't upgrade testing
-Explanation: packages unless explicitly asked to.
-Explanation: Install with apt-get install package/testing. But if dependencies are
-Explanation: needed, or need upgrading,
-Explanation: apt-get -t testing package, setting testing to priority
-Explanation: 990 just for that command.
-Explanation: Use apt-cache policy to verify these settings.
Package: *
Pin: release a=testing
Pin-Priority: 50
Package: *
Pin: release a=testing-updates
Pin-Priority: 50
-
-Explanation: Allow this testing package to automatically upgrade.
-Package: unison
-Pin-Piority: 100
--- /dev/null
+deb http://http.us.debian.org/debian jessie main
+deb-src http://http.us.debian.org/debian jessie main
+
+deb http://security.debian.org/ jessie/updates main
+deb-src http://security.debian.org/ jessie/updates main
+
+deb http://http.us.debian.org/debian jessie-updates main
+deb-src http://http.us.debian.org/debian jessie-updates main
deb http://security.debian.org/ testing/updates main
deb-src http://security.debian.org/ testing/updates main
-# jessie-updates, previously known as 'volatile'
deb http://http.us.debian.org/debian testing-updates main
deb-src http://http.us.debian.org/debian testing-updates main
--- /dev/null
+deb http://http.us.debian.org/debian unstable main
+deb-src http://http.us.debian.org/debian unstable main
+++ /dev/null
-deb http://httpredir.debian.org/debian jessie main contrib non-free
-deb http://httpredir.debian.org/debian-security jessie/updates main contrib non-free
+++ /dev/null
-# deb http://http.us.debian.org/debian jessie main
-
-deb http://http.us.debian.org/debian jessie main
-deb-src http://http.us.debian.org/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://http.us.debian.org/debian jessie-updates main
-deb-src http://http.us.debian.org/debian jessie-updates main
-
-
-deb http://http.us.debian.org/debian testing main
-deb-src http://http.us.debian.org/debian testing main
-
-deb http://security.debian.org/ testing/updates main
-deb-src http://security.debian.org/ testing/updates main
-
-# jessie-updates, previously known as 'volatile'
-deb http://http.us.debian.org/debian testing-updates main
-deb-src http://http.us.debian.org/debian testing-updates main
#### begin configuration
-partition=true # change to true to force a full wipe
bootn=3
rootn=1
swapn=2
##### end configuration
+if ifclass REPARTITION;then
+ partition=true # force a full wipe
+else
+ partition=false # change to true to force a full wipe
+fi
+
lastn=$bios_grubn
cd /mnt
for x in q home_$DISTRO root_$DISTRO; do
btrfs subvolume list . | grep "$x$" >/dev/null || btrfs subvolume create $x
+ chown root:1000 q
done
mkdir -p /mnt/root_$DISTRO/boot
for x in root/a q/a; do
fcopy -M /etc/apt/preferences
fi
+if ifclass DEBIAN; then
+ fcopy -M /etc/apt/preferences.d/unstable
+ fcopy -riM /etc/apt/sources.list.d
+fi
+
# -i, ignore nonmatching class error, always return 0.
fcopy -r -M -i /home/ian/.ssh
/var/lib/fai/config/distro-install-common/end
+rm -f /target/etc/apt/sources.list
-# could also use: chroot /target script-file
-$ROOTCMD chown -R 1000:1000 /home/ian/.ssh
-$ROOTCMD chmod -R u=Xrw,og= /home/ian/.ssh
-$ROOTCMD cp -ar /home/ian/.ssh /root
-$ROOTCMD chown -R root:root /root/.ssh
+chroot /target bash <<'EOF'
+chown -R 1000:1000 /home/ian/.ssh
+chmod -R u=Xrw,og= /home/ian/.ssh
+cp -ar /home/ian/.ssh /root
+chown -R root:root /root/.ssh
# default jessie groups + kvm & systemd-journal
-$ROOTCMD usermod -aG cdrom,floppy,sudo,audio,dip,video,plugdev,netdev,kvm,systemd-journal ian
-
+usermod -aG cdrom,floppy,sudo,audio,dip,video,plugdev,netdev,kvm,systemd-journal ian
+EOF
-$ROOTCMD apt-get -y install unison/testing
+if ifclass STABLE; then
+ apt-get -y install unison-gtk
+ apt-get -y install unison-gtk/testing
+fi