Created
November 15, 2013 14:12
-
-
Save abhishekkr/7484912 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
nspawn-ls(){ | |
echo "List of all nspawn instances..." | |
echo "Archlinux:" | |
for itm in `sudo ls "/srv/subarch/"`; do | |
echo $itm | |
done | |
echo "********************" | |
} | |
nspawn-start(){ | |
if [ $# -ne 1 ]; then | |
echo "Syntax: nspawn-start <name-of-spawned-instance-to-start>" | |
return | |
fi | |
sudo systemd-nspawn -bD "/srv/subarch/${1}" | |
} | |
nspawn-stop(){ | |
if [ $# -ne 1 ]; then | |
echo "Syntax: nspawn-stop <name-of-spawned-instance-to-stop>" | |
return | |
fi | |
sudo systemctl stop machine-${1}.scope | |
} | |
nspawn-arch(){ | |
NSPAWN_CACHE="$HOME/.nspawn-cache" | |
NSPAWN_CACHE_CHILD="${NSPAWN_CACHE}/srv/subarch/child01" | |
mkdir -p $NSPAWN_CACHE | |
cd $NSPAWN_CACHE | |
if [ ! -d $NSPAWN_CACHE_CHILD ]; then | |
curl -kLO https://googledrive.com/host/0B86nn-kptoWCWU9GdzUzWm9aTWs/arch.systemd-nspawn.tar.bz2 | |
tar jxvf arch.systemd-nspawn.tar.bz2 | |
fi | |
echo "\n\nCopying extracted SubArch files over to require directory..." | |
echo "\nWhen it asks for Username at log-in, just say 'root' or try your a/c.\n\n" | |
sudo mkdir -p "/srv/subarch/" | |
child_count=`ls -1l /srv/subarch/ | grep '^d' | wc -l` | |
NSPAWN_NEW_CHILD="/srv/subarch/child${child_count}" | |
sudo cp -ar $NSPAWN_CACHE_CHILD $NSPAWN_NEW_CHILD | |
echo "done.\n\nLogging in..." | |
sudo systemd-nspawn -bD $NSPAWN_NEW_CHILD | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment