3 # WARNING: looks like specifying another arch/preso won't work
8 #BUILD="${HOME}/git-build"
9 DOMAIN=pl.sophia.inria.fr
15 DISTRO=$DEFAULT_DISTRO
19 echo "usage : $COMMAND [-i] [-f distro] [-p perso] hostname"
20 echo " default distro is $DEFAULT_DISTRO"
21 echo " default perso is $DEFAULT_PERSO"
22 [ -n "$message" ] && echo $message
26 while getopts "f:p:ih" flag; do
30 i) INTERACTIVE=true ;;
35 [[ -z "$@" ]] && usage "no hostname provided"
37 [[ -n "$@" ]] && usage "extra arguments" "$@" "(hostname=$HOSTNAME)"
40 #[ -d "$BUILD" ] || usage "Could not find directory $BUILD"
42 [ -d /vservers/$HOSTNAME ] && usage "vserver $HOSTNAME already exists in /vservers"
43 # debian distros not found there - skip that
44 #[ -d /etc/vservers/.distributions/$DISTRO ] || usage "distro $DISTRO not known in /etc/vservers/.distributions/"
45 rpm -q debootstrap >& /dev/null || usage "You need to first run 'yum install debootstrap'"
47 fqdn=$HOSTNAME.$DOMAIN
49 host $fqdn | grep -q 'has address' || usage "hostname $fqdn not known to DNS"
50 ip=$(host $fqdn | grep 'has address' | awk '{print $4}')
56 # single_ip needs to be turned off, vtest-init-vserver now takes care of that
57 #command="$BUILD/vtest-init-vserver.sh -p $PERSO -f $DISTRO $HOSTNAME none -- --interface eth0:$ip --hostname $fqdn"
65 squeeze|wheezy) DEBMIRROR=http://ftp2.fr.debian.org/debian/ ;;
66 # from the vserver man page DEBMIRROR=http://us.archive.ubuntu.com/ubuntu/ ;;
67 oneiric|precise|quantal) DEBMIRROR=http://mir1.ovh.net/ubuntu/ubuntu/ ;;
68 *) echo unknown distro $DISTRO; exit 1;;
71 command="$PERSO vserver ${HOSTNAME} build -m debootstrap --interface eth0:${ip}/21 --hostname ${fqdn} -- -d ${DISTRO} -m ${DEBMIRROR} -- --verbose --arch=${arch} "
73 if [ -n "$INTERACTIVE" ] ; then
74 echo -n "Run $command OK ? "
75 read answer ; case $answer in [nN]*) exit 1 ;; esac
80 ## stolen from vbuild-util-vserver (might be that we can actually use that one as-is...)
81 # turns out that with wheezy at least, at this point we're getting
82 # /vservers/<vs>/var/run -> /run
83 # /vservers/<vs>/var/lock -> /run/lock
84 # trying to fix this with relative links does not appear to work fine
85 # when trying to vserver start we're then getting
86 # + exec /usr/sbin/vspace --mount --fs --new -- /usr/sbin/vserver ----nonamespace debuild09 start
87 # fakerunlevel: open("/var/run/utmp"): No such file or directory
88 # so instead we bluntly create empty dirs and hope for the best
89 [ -h /vservers/${HOSTNAME}/var/run ] && [ ! -d /vservers/${HOSTNAME}/var/run ] && \
90 { rm -f /vservers/${HOSTNAME}/var/run ; mkdir /vservers/${HOSTNAME}/var/run ; }
91 [ -h /vservers/${HOSTNAME}/var/lock ] && [ ! -d /vservers/${HOSTNAME}/var/lock ] && \
92 { rm -f /vservers/${HOSTNAME}/var/lock ; mkdir /vservers/${HOSTNAME}/var/lock ; }
94 vserver ${HOSTNAME} start