aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-06-01 22:14:26 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-06-01 22:14:26 +0200
commita1f34001696c44139b668918ea52c1add0dde7ea (patch)
treeaf4ea86dfe4ac5a696e3c9eb43935ab9ebb063d4
parentf33ea96125c63e112cbef97de3b8376a38681e40 (diff)
downloadltask-a1f34001696c44139b668918ea52c1add0dde7ea.tar.gz
fixed include system, updated some tasks
-rw-r--r--libs/pkgmanager12
-rwxr-xr-xltask10
-rw-r--r--tasks/initial-user-setup2
-rw-r--r--tasks/jenkins (renamed from tasks/apt-update)11
-rw-r--r--tasks/system-update (renamed from tasks/update)18
-rwxr-xr-xtools/rexec.sh12
6 files changed, 41 insertions, 24 deletions
diff --git a/libs/pkgmanager b/libs/pkgmanager
index 7c1efd3..7a5793a 100644
--- a/libs/pkgmanager
+++ b/libs/pkgmanager
@@ -1,5 +1,7 @@
# vi: ft=sh
+shopt -s expand_aliases
+alias sudo="sudo "
PKGMAN="/bin/false"
[ -f "/etc/os-release" ] && source /etc/os-release
@@ -22,8 +24,8 @@ case $ID in
;;
esac
-alias pkg_install="sudo $PKGMAN $INSTALL_CMD"
-alias pkg_remove="sudo $PKGMAN $REMOVE_CMD"
-alias pkg_update="sudo $PKGMAN $UPDATE_CMD"
-alias pkg_upgrade="sudo $PKGMAN $UPGRADE_CMD"
-alias pkg_fullupgrade="sudo $PKGMAN $FULLUPGRADE_CMD"
+alias pkg_install="$PKGMAN $INSTALL_CMD"
+alias pkg_remove="$PKGMAN $REMOVE_CMD"
+alias pkg_update="$PKGMAN $UPDATE_CMD"
+alias pkg_upgrade="$PKGMAN $UPGRADE_CMD"
+alias pkg_fullupgrade="$PKGMAN $FULLUPGRADE_CMD"
diff --git a/ltask b/ltask
index 1416e7f..864664f 100755
--- a/ltask
+++ b/ltask
@@ -109,7 +109,7 @@ for hoststring in "${HOSTS_UNIQUE[@]}"; do
[ ! -z $port ] && rexecargs+="-p $port "
rexecargs+="-i ${SSH_IDENTITY_FILE:=~/.ssh/id_rsa} "
- [ ${#FILES[@]} -gt 0 ] && rexecargs+="-f \"${FIELS[@]}\" "
+ [ ${#FILES[@]} -gt 0 ] && for f in ${FILES[@]}; do rexecargs+="-f $f "; done
[ ! -z $SSH_USER ] && rexecargs+="$SSH_USER@"
rexecargs+="$hostname ${INCLUDES[@]} $TASK_DIR/$TASK"
@@ -119,4 +119,12 @@ for hoststring in "${HOSTS_UNIQUE[@]}"; do
echo
echo $rexecargs
$TOOL_DIR/rexec.sh $rexecargs
+ [ $? -ne 0 ] && FAILED_HOSTS+=($hostname)
done
+
+if [ ${#FAILED_HOSTS[@]} -gt 0 ]; then
+ echo
+ echo Some hosts failed the task:
+ echo ${FAILED_HOSTS[@]}
+ exit 1
+fi
diff --git a/tasks/initial-user-setup b/tasks/initial-user-setup
index de3aee9..68a0d2a 100644
--- a/tasks/initial-user-setup
+++ b/tasks/initial-user-setup
@@ -5,7 +5,7 @@ function task_setup() {
SSH_IDENTITY_FILE=$ASSET_DIR/id_jenkins
FILES+=("$ASSET_DIR/id_user.pub" "$ASSET_DIR/id_jenkins.pub")
- INCLUDES+=("pkgmanager")
+ INCLUDES+=("$INCLUDE_DIR/pkgmanager")
TASK_ISSET="yes"
}
diff --git a/tasks/apt-update b/tasks/jenkins
index 38693b3..5598a9e 100644
--- a/tasks/apt-update
+++ b/tasks/jenkins
@@ -1,8 +1,9 @@
#!/bin/bash
function task_exec() {
- sudo apt-get -y update
- sudo apt-get -y upgrade
+
+ cat id_jenkins.pub >> /home/server/.ssh/authorized_keys
+
}
function task_setup() {
@@ -11,8 +12,10 @@ function task_setup() {
# $TOOL_DIR
SSH_USER=server
- SSH_IDENTITY_FILE=$ASSET_DIR/id_rsa
-
+ SSH_IDENTITY_FILE=$ASSET_DIR/id_jenkins
+
+ FILES+=("$ASSET_DIR/id_jenkins.pub")
+
TASK_ISSET="yes"
}
diff --git a/tasks/update b/tasks/system-update
index e392b76..8244ca4 100644
--- a/tasks/update
+++ b/tasks/system-update
@@ -1,18 +1,26 @@
#!/bin/bash
function task_exec() {
- pkg_update
- pkg_upgrade
+ ret=0
+ sudo pkg_update
+ ret=$(($ret + $?))
+
+ sudo pkg_upgrade
+ ret=$(($ret + $?))
+
+ exit $ret
}
function task_setup() {
+ # Available environment variables
+ # $ASSET_DIR
+ # $TOOL_DIR
+
INCLUDES+=("$INCLUDE_DIR/pkgmanager")
SSH_USER=server
- #SSH_IDENTITY_FILE=$ASSET_DIR/id_rsa
+ SSH_IDENTITY_FILE=$ASSET_DIR/id_jenkins
- FILES+=()
-
TASK_ISSET="yes"
}
diff --git a/tools/rexec.sh b/tools/rexec.sh
index 98652c4..558540c 100755
--- a/tools/rexec.sh
+++ b/tools/rexec.sh
@@ -30,7 +30,7 @@ SSH="ssh $SSH_OPTIONS"
SCRIPT_FILES=()
SCRIPT_INTERPRETER=/bin/sh
-FILES=""
+FILES=()
function parse_args() {
for (( i=0; i < $ARGC;i++ )); do
@@ -53,7 +53,7 @@ function parse_args() {
SSH_IDENTITY=${ARGV[$i]};;
-f)
i=$((i+1))
- FILES="${ARGV[$i]}";;
+ FILES+=(${ARGV[$i]});;
-h)
print_help 0;;
*)
@@ -85,11 +85,7 @@ EOF
parse_args
-#[ ! -f $SCRIPT_FILE ] && echo \"$SCRIPT_FILE\" not found && exit 1
+[ ${#FILES[@]} -gt 0 ] && scp $SSH_OPTIONS -i $SSH_IDENTITY -P $SSH_PORT ${FILES[@]} $SSH_HOST:
-#INTERPRETER_STRING=$(head -n 1 $SCRIPT_FILE)
-#INTERPRETER_REGEX="^#!.*"
-#[[ $INTERPRETER_STRING =~ $INTERPRETER_REGEX ]] && SCRIPT_INTERPRETER=$(tail -c +3 <<< $INTERPRETER_STRING)
-
-[ ! -z "$FILES" ] && scp -S "$SSH" -i $SSH_IDENTITY -P $SSH_PORT $FILES $SSH_HOST:
cat ${SCRIPT_FILES[@]} | $SSH -p $SSH_PORT -i $SSH_IDENTITY $SSH_HOST "/bin/bash"
+exit $?