about summary refs log tree commit diff stats
path: root/core/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'core/scripts')
-rw-r--r--core/scripts/setup-iso.sh103
1 files changed, 85 insertions, 18 deletions
diff --git a/core/scripts/setup-iso.sh b/core/scripts/setup-iso.sh
index 11a38bc..ddad787 100644
--- a/core/scripts/setup-iso.sh
+++ b/core/scripts/setup-iso.sh
@@ -1,19 +1,18 @@
 #!/bin/sh
 
-ISO_DIR=$1
-CHROOT="/mnt"
-
-ISO_URL="https://serverop.de/crux/crux-3.3/iso/crux-3.3.iso"
-MD5_URL="https://serverop.de/crux/crux-3.3/iso/crux-3.3.md5"
-
-ISO_FILE="${ISO_DIR}/crux-3.3.iso"
-MD5_FILE="${ISO_DIR}/crux-3.3.md5"
+# location of iso and md5 file
+ISO_DIR="/usr/ports/iso"
 
+ISO_FILE="${ISO_DIR}/crux-3.4.iso"
+MD5_FILE="${ISO_DIR}/crux-3.4.md5"
 
+# iso and md5 remote location
+#ISO_URL="https://serverop.de/crux/crux-3.4/iso/crux-3.4.iso"
+ISO_URL="https://ftp.spline.inf.fu-berlin.de/pub/crux/crux-3.4/iso/crux-3.4.iso"
+MD5_URL="https://serverop.de/crux/crux-3.4/iso/crux-3.4.md5"
 
 # First we define the function
-ConfirmOrExit ()
-{
+ConfirmOrExit () {
     while true
     do
         echo -n "Please confirm (y or n) :"
@@ -30,7 +29,7 @@ ConfirmOrExit ()
     echo "You entered $CONFIRM. Continuing ..."
 }
 
-prepare_iso() {
+download_iso() {
 
     mkdir -p ${ISO_DIR}
 
@@ -50,22 +49,90 @@ prepare_iso() {
         cd ${ISO_DIR} && { curl -k -O ${MD5_URL} ; cd -; }
     fi
 
+}
+
+check_iso() {
     if  cd ${ISO_DIR} && md5sum -c ${MD5_FILE} ;
     then
         echo "Valid iso md5sum"
     else
         echo "Invalid iso md5sum"
     fi
+}
+
+mount_iso() {
+
+    if [ ! -f $ISO_FILE ];
+    then
+        echo "File $ISO_FILE does not exist."
+        exit 0
+    fi
 
     modprobe isofs
     modprobe loop
-    mount -o loop $ISO_FILE $CHROOT/media
+    mount -o loop $ISO_FILE /media
+}
+
+print_data() {
+    echo "1.1.1 Paths to iso and md5 files:"
+    echo "iso dir: ${ISO_DIR}"
+    echo "iso file: ${ISO_FILE}"
+    echo "md5 file: ${MD5_FILE}"
+    echo "iso url: ${ISO_URL}"
+    echo "md5 url: ${MD5_URL}"
 }
 
-echo "1.1.1 Paths to iso and md5 files:"
-echo "dir: ${ISO_DIR}"
-echo "iso url: ${ISO_URL}"
-echo "md5 url: ${MD5_URL}"
+print_help() {
+	echo "usage: setup-iso [options]"
+	echo "options:"
+	echo "  -r,   --root                default dir is /usr/ports/iso"
+	echo "  -d,   --download            download iso"
+	echo "  -c,   --check               check iso md5sum"
+	echo "  -m,   --mount               mount iso on /media "
+	echo "  -h,   --help                print help and exit"
+}
+
+while [ "$1" ]; do
+            case $1 in
+                    -r|--root)
+                        ISO_DIR=$2
+
+                        ISO_FILE="${ISO_DIR}/crux-3.4.iso"
+                        MD5_FILE="${ISO_DIR}/crux-3.4.md5"
+
+                        shift ;;
+                    -d|--download)
+                        echo "Download iso:"
+                        echo "_____________________"
+                        print_data
+                        ConfirmOrExit
+                        download_iso
+                        exit 0 ;;
+                    -c|--check)
+                        echo "Check iso md5sum:"
+                        echo "_____________________"
+                        print_data
+                        ConfirmOrExit
+                        check_iso
+                        exit 0 ;;
+                   -m|--mount)
+                        echo "Check iso md5sum:"
+                        echo "_____________________"
+                        print_data
+                        ConfirmOrExit
+                        mount_iso
+                        exit 0 ;;
+                    -h|--help)
+                        print_help
+                        exit 0 ;;
+                    *)
+                        echo "setup-iso: invalid option $1"
+                        print_help
+                        exit 1 ;;
+            esac
+            shift
+done
 
-ConfirmOrExit
-prepare_iso
+echo "setup-iso: no option provided"
+print_help
+exit 1