diff options
author | Simon Rettberg | 2015-09-18 17:11:21 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-09-18 17:11:21 +0200 |
commit | 14c261bc71f7adffb607d8762b185c4cef932393 (patch) | |
tree | 6ffe7510b2700c17c9f130b4d2b999205d997222 | |
parent | minor changes (diff) | |
download | tmlite-bwlp-14c261bc71f7adffb607d8762b185c4cef932393.tar.gz tmlite-bwlp-14c261bc71f7adffb607d8762b185c4cef932393.tar.xz tmlite-bwlp-14c261bc71f7adffb607d8762b185c4cef932393.zip |
Update
-rwxr-xr-x | scripts/mount-store | 9 | ||||
-rwxr-xr-x | scripts/system-restore | 42 | ||||
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/BackupRestore.java | 33 | ||||
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java | 4 | ||||
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java | 2 | ||||
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/Systemctl.java (renamed from src/main/java/org/openslx/taskmanager/tasks/DozmodLauncher.java) | 35 |
6 files changed, 82 insertions, 43 deletions
diff --git a/scripts/mount-store b/scripts/mount-store index cd777a8..260b0c7 100755 --- a/scripts/mount-store +++ b/scripts/mount-store @@ -56,11 +56,17 @@ fi # Unmount and not requested to mount (local mode) if [[ "${SOURCE}" == "null" ]]; then rm -f "${FLAG}" + echo "Success. Now using internal storage." exit 0 fi touch "${FLAG}" +if [[ "${SOURCE}" == "unknown" ]]; then + echo "Storage type not configured, doing nothing." + exit 0 +fi + # Mount! if grep -E -q '^[^/].+:.+' <<<$SOURCE; then @@ -94,7 +100,8 @@ echo "----------------------------------" if [ "$RET" == "0" ]; then rm -f "${FLAG}" if [ -e "${FLAG}" ]; then - echo "Error: File '.notmounted' exists on remote storage. Delete first!" >&2 + echo "Error: File '.notmounted' exists on remote storage and could not be deleted." >&2 + echo "Error: Make sure the share is writable." >&2 umount -v "$DEST" exit 5 fi diff --git a/scripts/system-restore b/scripts/system-restore index 8a66558..7b0de12 100755 --- a/scripts/system-restore +++ b/scripts/system-restore @@ -1,29 +1,33 @@ #!/bin/bash -RES_OPENSLX=0 -RES_SAT=0 -case "$1" in - both) - RES_OPENSLX=1 - RES_SAT=1 - ;; - openslx) - RES_OPENSLX=1 - ;; - sat) - RES_SAT=1 - ;; - *) - echo "Error: Restore mode must be one of both, openslx, sat" - exit 1 - ;; -esac - BACKUP="$1" if [ -z "$BACKUP" ] || [ ! -f "$BACKUP" ]; then echo "Backup file not found: $BACKUP" exit 1 fi +shift + +RES_OPENSLX=0 +RES_SAT=0 +while [ $# -gt 0 ]; do + case "$1" in + openslx) + RES_OPENSLX=1 + echo "Restoring system config" + ;; + dozmod) + RES_SAT=1 + echo "Restoring VM and lecture db" + ;; + *) + echo "Error: Restore mode params must be one of openslx, dozmod (Got $1)" + exit 1 + ;; + esac + shift +done + +[ "$RES_OPENSLX$RES_SAT" = "00" ] && exit 1 if [ "$(whoami)" != "root" ]; then echo "Must be running as root!" diff --git a/src/main/java/org/openslx/taskmanager/tasks/BackupRestore.java b/src/main/java/org/openslx/taskmanager/tasks/BackupRestore.java index bbb68f5..20f5363 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/BackupRestore.java +++ b/src/main/java/org/openslx/taskmanager/tasks/BackupRestore.java @@ -1,5 +1,8 @@ package org.openslx.taskmanager.tasks; +import java.util.ArrayList; +import java.util.List; + import org.openslx.satserver.util.Constants; import org.openslx.taskmanager.api.SystemCommandTask; @@ -11,6 +14,10 @@ public class BackupRestore extends SystemCommandTask private String mode; @Expose private String backupFile; + @Expose + private boolean restoreOpenslx; + @Expose + private boolean restoreDozmod; private Output status = new Output(); @@ -37,14 +44,24 @@ public class BackupRestore extends SystemCommandTask @Override protected String[] initCommandLine() { - if ( backupFile == null ) - backupFile = "ignored"; - return new String[] { - "/usr/bin/sudo", - "-n", - "-u", "root", Constants.BASEDIR + "/scripts/system-" + mode, - backupFile - }; + List<String> args = new ArrayList<>(); + args.add( "/usr/bin/sudo" ); + args.add( "-n" ); + args.add( "-u" ); + args.add( "root" ); + args.add( Constants.BASEDIR + "/scripts/system-" + mode ); + if ( mode.equals( "restore" ) ) { + if ( backupFile != null ) { + args.add( backupFile ); + } + if ( restoreDozmod ) { + args.add( "dozmod" ); + } + if ( restoreOpenslx ) { + args.add( "openslx" ); + } + } + return args.toArray( new String[ args.size() ] ); } @Override diff --git a/src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java b/src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java index 8fb8287..9a5022f 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java +++ b/src/main/java/org/openslx/taskmanager/tasks/CreateLdapConfig.java @@ -75,7 +75,7 @@ public class CreateLdapConfig extends AbstractTask try { // Generate keys { - int ret = Exec.sync( 10, "openssl", "req", + int ret = Exec.sync( 20, "openssl", "req", "-x509", "-new", "-newkey", "rsa:4096", "-keyout", keyFile, "-out", certFile, "-days", "5000", "-nodes", "-subj", "/C=DE/ST=Nowhere/L=Springfield/O=Dis/CN=" + this.proxyip ); if ( ret == -1 ) { @@ -137,7 +137,7 @@ public class CreateLdapConfig extends AbstractTask "-u", "root", Constants.BASEDIR + "/scripts/ldadp-setperms", Integer.toString( this.moduleid ) ) ) - status.error = "Could not chown/chmod ldadp config!"; + status.error = "Warning: Could not chown/chmod ldadp config!"; } catch ( IOException e ) { status.error = e.toString(); return false; diff --git a/src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java b/src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java index 37d09d8..3e641a5 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java +++ b/src/main/java/org/openslx/taskmanager/tasks/LdapSearch.java @@ -157,7 +157,7 @@ public class LdapSearch extends SystemCommandTask this.userCount++; } } - if ( this.getDn && line.startsWith( "dn: " ) ) { + if ( line.startsWith( "dn: " ) ) { status.dn = line.substring( 4 ); } } diff --git a/src/main/java/org/openslx/taskmanager/tasks/DozmodLauncher.java b/src/main/java/org/openslx/taskmanager/tasks/Systemctl.java index 0061a4f..43df01b 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/DozmodLauncher.java +++ b/src/main/java/org/openslx/taskmanager/tasks/Systemctl.java @@ -1,14 +1,13 @@ package org.openslx.taskmanager.tasks; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.openslx.taskmanager.api.SystemCommandTask; import com.google.gson.annotations.Expose; -public class DozmodLauncher extends SystemCommandTask +public class Systemctl extends SystemCommandTask { /** * What to do: start, stop... @@ -16,29 +15,41 @@ public class DozmodLauncher extends SystemCommandTask @Expose private String operation; + @Expose + String service; + private StatusObject status = new StatusObject(); @Override protected String[] initCommandLine() { - List<String> params = new ArrayList<>(); - params.addAll( - Arrays.asList( - "/usr/bin/sudo", - "-n", - "-u", "dmsd", - "/opt/dmsd/control.sh" ) ); switch ( operation ) { case "start": case "stop": - params.add( operation ); + case "enable": + case "disable": break; default: status.addMsg( "Unknown operation: " + operation ); return null; } - this.timeoutSeconds = 5; - return params.toArray( new String[ 0 ] ); + switch ( service ) { + case "dmsd": + break; + default: + status.addMsg( "Unknown service: " + operation ); + return null; + } + List<String> params = new ArrayList<>(); + params.add( "/usr/bin/sudo" ); + params.add( "-n" ); + params.add( "-u" ); + params.add( "root" ); + params.add( "/bin/systemctl" ); + params.add( operation ); + params.add( service ); + this.timeoutSeconds = 10; + return params.toArray( new String[ params.size() ] ); } private boolean errorIfNull( String check, String message ) |