diff options
author | Jonathan Bauer | 2015-05-27 18:24:18 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-05-27 18:24:18 +0200 |
commit | 578deaa14ca89020487ecadeb0982e7a3d433545 (patch) | |
tree | a1445b946059b2c6ec0066946b013c8e481be6b7 /mltk-ng | |
parent | restructuring & bit of documentation ;) (diff) | |
download | systemd-init-578deaa14ca89020487ecadeb0982e7a3d433545.tar.gz systemd-init-578deaa14ca89020487ecadeb0982e7a3d433545.tar.xz systemd-init-578deaa14ca89020487ecadeb0982e7a3d433545.zip |
DO NOT USE YET. YOU'VE BEEN WARNED!!111
Diffstat (limited to 'mltk-ng')
-rwxr-xr-x | mltk-ng | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/mltk-ng b/mltk-ng new file mode 100755 index 00000000..74503307 --- /dev/null +++ b/mltk-ng @@ -0,0 +1,66 @@ +#!/bin/bash +# ------------------------------------------------------------------------------ +# +# Mini-Linux Toolkit Next Gen +# +# ------------------------------------------------------------------------------ + +declare -rg ARG0="$0" +declare -rg SELF="$(readlink -f "$ARG0")" +declare -rg ROOT_DIR="$(dirname "${SELF}")" +declare -rg MLTK_PID="$$" + +banner() { + echo -e "\033[38;5;202m\t __ __ __ " + echo -e "\033[38;5;202m\t.--------.| | | |_| |--." + echo -e "\033[38;5;208m\t| || |_| _| < " + echo -e "\033[38;5;214m\t|__|__|__||____|____|__|__|" + echo -e "\033[38;5;214m\t " + echo -e "\033[38;5;220m\t ** OpenSLX Project // 2015 **" + echo -e "\033[38;5;226m\t http://lab.openslx.org/" + echo -e "\033[00m" +} + + +pinfo() { + echo -e "\033[38;5;10m[info]\033[0m $@" +} + +perror() { + echo -e "\033[38;5;9m[error]\033[0m $@" + kill "$MLTK_PID" + exit 1 +} + +print_usage() { + perror "./mltk-ng <remote_ip> <stage4_sync_dir> <target_qcow2_container>" +} + +# root check +if [ "$(id -u)" -ne 0 ]; then + perror "ERROR: You need to be root to use this toolkit." +else + banner +fi + +# do we even have tools? +for TOOL in qemu-img qemu-nbd mkfs.ext4; do + which $TOOL &>/dev/null || perror "Could not find '$TOOL'." +done + +# let's keep it simple for now, just source our main functions file +. ${ROOT_DIR}/mltk-ng.functions || perror "Could not source functions." + +# ok, now check that we have 3 args +[ $# -ne 3 ] && print_usage + +# even though functions check their parameter, we also do it to be safe. +valid_ip "$1" || perror "'$1' is not a valid IP adress, aborting..." +[ ! -d "$2" ] || perror "'$2' already exists, aborting..." +[ ! -f "$3" ] || perror "'$3' already exists, aborting..." + +# all good, let's start +pinfo " ## RUNNING ##" +clone_stage4 $1 $2 +export_qcow2 $2 $3 +pinfo " ## COMPLETE ##" |