Commit 871061ae authored by Jonathan Bryant's avatar Jonathan Bryant 💬

Update distro.sh

parent bb05e8de
......@@ -3,18 +3,17 @@
FILES="authorized_keys ssh_host_key container_token"
check_penguin() {
if [ -z "$(lxc ls | grep 'penguin | RUNNING')" ]; then
if [ -z "$(/usr/bin/lxc ls | /bin/grep 'penguin | RUNNING')" ]; then
echo "Opps. Penguin is not running. This might be fixable by just running: lxc start penguin"
exit 1
fi
}
get_file() {
check_penguin
# Workaround for the read protected files at rest.
local PATH="/mnt/stateful/lxd/devices/penguin/disk.$1.dev-.$1"
if [ -f $PATH ]; then
echo "$(cat $PATH)"
echo "$(/bin/cat $PATH)"
else
echo "Cannot find $1."
exit 1
......@@ -22,7 +21,6 @@ get_file() {
}
values_penguin() {
check_penguin
for x in ${FILES}; do
# Creates a variable named after an item in $FILES and assigns it the value of the file.
eval "$x=$(get_file $x)"
......@@ -30,16 +28,16 @@ values_penguin() {
}
user_penguin() {
check_penguin
USER="$(lxc exec penguin -- ls /home)"
USER="$(/usr/bin/lxc exec penguin -- ls /home)"
echo "${USER[0]}"
}
swap_penguin() {
values_penguin
lxc stop penguin --force
lxc rename penguin stretch
run_container.sh --container_name="penguin" --user="$(user_penguin)" --image="$1" --lxd_remote="https://images.linuxcontainers.com" --container_token="$container_token" --host_public_key="$ssh_host_key" --guest_private_key="$authorized_keys"
/usr/bin/lxc stop penguin --force
/usr/bin/lxc rename penguin stretch
/usr/bin/run_container.sh --container_name="penguin" --user="$(user_penguin)" --image="$1" --lxd_remote="https://images.linuxcontainers.com" --container_token="$container_token" --host_public_key="$ssh_host_key" --guest_private_key="$authorized_keys"
}
check_penguin
swap_penguin $1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment