#!/bin/bash
+usage() {
+cat <<EOF
+ $0 [options]
+ --help,-h This help
+ --vps vps_name Name of the vps
+ --password password Password of the vps (only useful in case of no reboot)
+ --reinstall-first Start with reinstalling the vps
+ --host-user user Use another user (default: root)
+ --no-reboot Don't reboot
+ --no-reboot-start Don't reboot to rescue at the beginning
+ --no-reboot-end Don't reboot to normal at the end
+ --git-branch Use another puppet branch (default: master)
+ --environment Environment to use for the installl (default: production)
+EOF
+}
+
set -e
host_user=root
git_branch=master
+environment=production
while [ -n "$1" ]; do
case "$1" in
git_branch="$2"
shift
;;
+ --environment)
+ environment="$2"
+ shift
+ ;;
+ --help|-h)
+ usage
+ exit 0
+ ;;
esac
shift
echo 'Server = http://archlinux.mirrors.ovh.net/archlinux/\$repo/os/\$arch' > /tmp/root.x86_64/etc/pacman.d/mirrorlist
-DEVICE_STR=\$(cat /proc/mounts | grep "/dev/sd.. /mnt/")
+DEVICE_STR=\$(cat /proc/mounts | grep "/dev/[sv]d.. /mnt/")
DEVICE=\$(echo "\$DEVICE_STR" | cut -d' ' -f1)
MOUNTPOINT=\$(echo "\$DEVICE_STR" | cut -d' ' -f2)
CODE_PATH="/etc/puppetlabs/code"
rm -rf \$CODE_PATH
git clone -b $git_branch --recursive https://git.immae.eu/perso/Immae/Projets/Puppet.git \$CODE_PATH
-puppet apply --test \$CODE_PATH/manifests/site.pp
+puppet apply --environment $environment --tags base_installation --test \$CODE_PATH/manifests/site.pp
# The password seed requires puppet to be run twice
-puppet apply --test \$CODE_PATH/manifests/site.pp
+puppet apply --environment $environment --tags base_installation --test \$CODE_PATH/manifests/site.pp
EOF
chmod a+x $ARCH_HOST_SCRIPT $ARCH_CHROOT_SCRIPT $ARCH_INSTALL_SCRIPT
cat > $ARCH_PUPPET_CONFIGURATION_SCRIPT <<EOF
CODE_PATH="/etc/puppetlabs/code"
-puppet apply --test \$CODE_PATH/manifests/site.pp
+puppet apply --environment $environment --tags base_installation --test \$CODE_PATH/manifests/site.pp
EOF
cat > $ARCH_HOST_PUPPET_CONFIGURATION_SCRIPT <<EOF
-DEVICE_STR=\$(cat /proc/mounts | grep "/dev/sd.. /mnt/")
+DEVICE_STR=\$(cat /proc/mounts | grep "/dev/[sv]d.. /mnt/")
DEVICE=\$(echo "\$DEVICE_STR" | cut -d' ' -f1)
MOUNTPOINT=\$(echo "\$DEVICE_STR" | cut -d' ' -f2)