diff --git a/Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz b/Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz index 4b481d5..3e4ac94 100644 Binary files a/Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz and b/Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz differ diff --git a/Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz.sha256 b/Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz.sha256 index 9ff5bc6..8eec587 100644 --- a/Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz.sha256 +++ b/Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz.sha256 @@ -1 +1 @@ -fbb7bc5eb954b47a29361127045102c4421760e1456bab17c43793ec0434f2b6 Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz +c775381cbf3612f9b9941816ff8f0597c7de4dfac59d9ce3ec33fb675d3f2be4 Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz diff --git a/bin/BIG-IP-ILX-WebSSH2-current.tgz b/bin/BIG-IP-ILX-WebSSH2-current.tgz index 4b481d5..3e4ac94 100644 Binary files a/bin/BIG-IP-ILX-WebSSH2-current.tgz and b/bin/BIG-IP-ILX-WebSSH2-current.tgz differ diff --git a/bin/BIG-IP-ILX-WebSSH2-current.tgz.sha256 b/bin/BIG-IP-ILX-WebSSH2-current.tgz.sha256 index 9ff5bc6..8eec587 100644 --- a/bin/BIG-IP-ILX-WebSSH2-current.tgz.sha256 +++ b/bin/BIG-IP-ILX-WebSSH2-current.tgz.sha256 @@ -1 +1 @@ -fbb7bc5eb954b47a29361127045102c4421760e1456bab17c43793ec0434f2b6 Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz +c775381cbf3612f9b9941816ff8f0597c7de4dfac59d9ce3ec33fb675d3f2be4 Build/Release/BIG-IP-ILX-WebSSH2-0.2.8.tgz diff --git a/scripts/build.sh b/scripts/build.sh index 3cd4c39..cb7a4d8 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,21 +1,33 @@ #!/bin/bash ## Syncs from BIG-IP and builds a release based on version in extensions/ephemeral_auth/package.json - +# source ./scripts/env.sh - source ./scripts/util.sh ./scripts/pull.sh +# get version of package from package.json package_version=$(jq -r ".version" workspace/extensions/webssh2/package.json) - +# creates new workspace name with version webssh_workspace_name=$webssh_workspace_name-$package_version -ssh -o ClearAllForwardings=yes $webssh_ilxhost /bin/tar czf - -C /var/ilx/workspaces/Common/$webssh_workspace_name . > Build/Release/$webssh_package_name-$package_version.tgz +echoNotice "Creating workspace package" +runCommand "ssh -o ClearAllForwardings=yes $webssh_ilxhost /bin/tar --exclude='./extensions/webssh2/config.json' -czf - -C /var/ilx/workspaces/Common/$webssh_workspace_name . > Build/Release/$webssh_package_name-$package_version.tgz" -shasum -a 256 Build/Release/$webssh_package_name-$package_version.tgz > Build/Release/$webssh_package_name-$package_version.tgz.sha256 +echoNotice "Creating SHA256 hash" +runCommand "shasum -a 256 Build/Release/$webssh_package_name-$package_version.tgz > Build/Release/$webssh_package_name-$package_version.tgz.sha256" -cp Build/Release/$webssh_package_name-$package_version.tgz $webssh_pua_location/$webssh_package_name-current.tgz -cp Build/Release/$webssh_package_name-$package_version.tgz.sha256 $webssh_pua_location/$webssh_package_name-current.tgz.sha256 +echoNotice "Copying to current" +runCommand "cp Build/Release/$webssh_package_name-$package_version.tgz $webssh_pua_location/$webssh_package_name-current.tgz && \ + cp Build/Release/$webssh_package_name-$package_version.tgz.sha256 $webssh_pua_location/$webssh_package_name-current.tgz.sha256" -find . -name '.DS_Store' -type f -delete +echoNotice "Deleting any '.DS_Store' files" +runCommand "find . -name '.DS_Store' -type f -delete" + +echo -e "\nWorkspace packages located at:\n" +echo " Build/Release/$webssh_package_name-$package_version.tgz" +echo " Build/Release/$webssh_package_name-$package_version.tgz.sha256" +echo " $webssh_pua_location/$webssh_package_name-current.tgz" +echo " $webssh_pua_location/$webssh_package_name-current.tgz.sha256" + +echo -e "\nšŸ‘ Build Complete šŸ‘\n" diff --git a/scripts/env.sh b/scripts/env.sh index ea52c4e..1955d68 100755 --- a/scripts/env.sh +++ b/scripts/env.sh @@ -1,5 +1,4 @@ #!/bin/sh - #webssh_ilxhost=root@192.168.30.209 webssh_ilxhost=root@192.168.30.203 webssh_workspace_name=webssh2 diff --git a/scripts/pull.sh b/scripts/pull.sh index dd51cf9..e88d0ef 100755 --- a/scripts/pull.sh +++ b/scripts/pull.sh @@ -6,37 +6,23 @@ # # Pulls an ILX workspace from a BIG-IP and syncs to ./workspace, excludes # ./workspace/extensions/ephemeral_auth/node_modules. - +# source ./scripts/env.sh - source ./scripts/util.sh +# get version of package from package.json PACKAGE_VERSION=$(jq -r ".version" workspace/extensions/webssh2/package.json 2>&1) - +# creates new workspace name with version webssh_workspace_name=$webssh_workspace_name-$PACKAGE_VERSION +echo "Pull ${fgLtCya}$webssh_workspace_name${fgLtWhi} from ${fgLtCya}$webssh_ilxhost${fgLtWhi}" + # check to see if the workspace actually exists before attempting to copy over -output=$(ssh -o ClearAllForwardings=yes $webssh_ilxhost tmsh list ilx workspace $webssh_workspace_name one-line 2>&1) -result="$?" 2>&1 +echoNotice "Checking for existing workspace ${fgLtCya}$webssh_workspace_name${fgLtWhi}" +runCommand "ssh -o ClearAllForwardings=yes $webssh_ilxhost tmsh list ilx workspace $webssh_workspace_name one-line 2>&1" -if [ $result -ne 0 ]; then - echo -e "\n\n" - echo "Workspace: $webssh_workspace_name not found, are you sure that's the right one?" - echo -e "\n\n" - echo "Terminating." - echo -e "\n\n" - exit 255 -fi +echoNotice "Pulling ${fgLtCya}$webssh_workspace_name${fgLtWhi} from ${fgLtCya}$webssh_ilxhost${fgLtWhi}" +runCommand "rsync -e 'ssh -o ClearAllForwardings=yes -ax' -avq --include=\"extensions/ephemeral_auth/node_modules/f5-*\" --exclude=\".DS_Store\" --exclude=\"extensions/ephemeral_auth/node_modules/*\" $webssh_ilxhost:/var/ilx/workspaces/Common/$webssh_workspace_name/. workspace/. 2>&1" -output=$(rsync -e 'ssh -o ClearAllForwardings=yes -ax' -avq --include="extensions/ephemeral_auth/node_modules/f5-*" --exclude=".DS_Store" --exclude="extensions/ephemeral_auth/node_modules/*" $webssh_ilxhost:/var/ilx/workspaces/Common/$webssh_workspace_name/. workspace/. 2>&1) -result="$?" 2>&1 - -if [ $result -ne 0 ]; then - echo -e "\n\n" - echo "Something went wrong with the rsync..." - echo -e "\n\n" - echo "Terminating." - echo -e "\n\n" - exit 255 -fi \ No newline at end of file +echo -e "\nšŸ‘ Pull complete šŸ‘\n" diff --git a/scripts/push.sh b/scripts/push.sh index 3bcd2da..57c9bc4 100755 --- a/scripts/push.sh +++ b/scripts/push.sh @@ -6,86 +6,54 @@ # # Pushes ./workspace to a BIG-IP ILX workspace # - source ./scripts/env.sh - source ./scripts/util.sh # get version of package from package.json PACKAGE_VERSION=$(jq -r ".version" workspace/extensions/webssh2/package.json 2>&1) - # creates new workspace name with version webssh_workspace_name=$webssh_workspace_name-$PACKAGE_VERSION -echo -e "\n" -echo "Checking $webssh_ilxhost for workspace $webssh_workspace_name" +echo "Push ${fgLtCya}$webssh_workspace_name${fgLtWhi} to ${fgLtCya}$webssh_ilxhost${fgLtWhi}" + +echoNotice "Checking $webssh_ilxhost for workspace $webssh_workspace_name" output=$(ssh -o ClearAllForwardings=yes $webssh_ilxhost tmsh list ilx workspace $webssh_workspace_name one-line 2>&1) result="$?" 2>&1 - if [ $result -ne 0 ]; then - echo -e "\n" - echo "Workspace: $webssh_workspace_name not found, attempting to create" - echo -e "\n\n" - output=$(ssh -o ClearAllForwardings=yes $webssh_ilxhost "tmsh create ilx workspace $webssh_workspace_name node-version 6.9.1" 2>&1) - result="$?" 2>&1 - if [ $result -ne 0 ]; then - echo -e "\n\n" - echo "Error creating workspace: $webssh_workspace_name... I give up, not sure what's going on..." - echo -e "\n\n" - exit 255 - fi + echo "āŒ" + echoNotice "Attempting to create workspace" + runCommand "ssh -o ClearAllForwardings=yes $webssh_ilxhost \"tmsh create ilx workspace $webssh_workspace_name node-version 6.9.1\" 2>&1" +else + echo "āœ…" fi -echo -e "\n" -echo "Pushing ./workspace to $webssh_ilxhost at $webssh_workspace_name" -rsync -e 'ssh -o ClearAllForwardings=yes -ax' -avq --delete --exclude='.DS_Store' --exclude extensions/webssh2/node_modules workspace/. $webssh_ilxhost:/var/ilx/workspaces/Common/$webssh_workspace_name/. +echoNotice "Pushing ./workspace to $webssh_ilxhost at $webssh_workspace_name" +runCommand "rsync -e 'ssh -o ClearAllForwardings=yes -ax' -avq --delete --exclude='.DS_Store' --exclude extensions/webssh2/node_modules workspace/. $webssh_ilxhost:/var/ilx/workspaces/Common/$webssh_workspace_name/." -echo -e "\n" -echo "Installing node modules at $webssh_workspace_name on $webssh_ilxhost" -output=$(ssh -o ClearAllForwardings=yes $webssh_ilxhost "cd /var/ilx/workspaces/Common/$webssh_workspace_name/extensions/webssh2; npm i --production" 2>&1) -result="$?" 2>&1 +echoNotice "Installing node modules at $webssh_workspace_name on $webssh_ilxhost" +runCommand "ssh -o ClearAllForwardings=yes $webssh_ilxhost \"cd /var/ilx/workspaces/Common/$webssh_workspace_name/extensions/webssh2; npm i --production\" 2>&1" -if [ $result -ne 0 ]; then - echo -e "\n" - echo "Error installing modules \"npm i --production\", process incomplete." - echo -e "\n" - echo "See output below:" - echo -e "\n" - echo $output - - exit 255 -fi - -echo -e "\n" -echo "Setting permissions at $webssh_workspace_name on $webssh_ilxhost" -output=$(ssh -o ClearAllForwardings=yes $webssh_ilxhost "chown -R root.sdm /var/ilx/workspaces/Common/$webssh_workspace_name/; \ +echoNotice "Setting permissions at $webssh_workspace_name on $webssh_ilxhost" +runCommand "ssh -o ClearAllForwardings=yes $webssh_ilxhost \"chown -R root.sdm /var/ilx/workspaces/Common/$webssh_workspace_name/; \ chmod -R ug+rwX,o-w /var/ilx/workspaces/Common/$webssh_workspace_name/; \ chmod u+rw,go-w /var/ilx/workspaces/Common/$webssh_workspace_name/version; \ - chmod u+rw,go-w /var/ilx/workspaces/Common/$webssh_workspace_name/node_version" 2>&1) -result="$?" 2>&1 -if [ $result -ne 0 ]; then - echo -e "\n\n" - echo "Error setting permissions... I give up, not sure what's going on..." - echo -e "\n\n" - exit 255 -fi + chmod u+rw,go-w /var/ilx/workspaces/Common/$webssh_workspace_name/node_version\" 2>&1" -echo -e "\n" -echo "Deleting $webssh_workspace_name/node_modules/.bin on $webssh_ilxhost" -output=$(ssh -o ClearAllForwardings=yes $webssh_ilxhost "cd /var/ilx/workspaces/Common/$webssh_workspace_name/extensions/webssh2; rm -rf node_modules/.bin" 2>&1) -result="$?" 2>&1 +echoNotice "Deleting $webssh_workspace_name/node_modules/.bin on $webssh_ilxhost" +runCommand "ssh -o ClearAllForwardings=yes $webssh_ilxhost \"cd /var/ilx/workspaces/Common/$webssh_workspace_name/extensions/webssh2; rm -rf node_modules/.bin\" 2>&1" -echo "Switching plugin to new workspace..." # switch plugin to new workspace -output=$(ssh -o ClearAllForwardings=yes $webssh_ilxhost tmsh modify ilx plugin WebSSH_plugin from-workspace $webssh_workspace_name 2>&1) +echoNotice "Checking to see if plugin exists" +output=$(ssh -o ClearAllForwardings=yes $webssh_ilxhost tmsh list ilx plugin WebSSH_plugin one-line 2>&1) result="$?" 2>&1 if [ $result -ne 0 ]; then - echo -e "\n\n" - echo "I give up, not sure what's going on..." - echo -e "\n\n" - exit 255 + echo "āŒ" + echoNotice "Attempting to create plugin" + runCommand "ssh -o ClearAllForwardings=yes $webssh_ilxhost tmsh create ilx plugin WebSSH_plugin from-workspace $webssh_workspace_name extensions { webssh2 { concurrency-mode single ilx-logging enabled } } 2>&1" +else + echo "āœ…" + echoNotice "Switching plugin to $webssh_workspace_name" + runCommand "ssh -o ClearAllForwardings=yes $webssh_ilxhost tmsh modify ilx plugin WebSSH_plugin from-workspace $webssh_workspace_name extensions { webssh2 { concurrency-mode single ilx-logging enabled } } 2>&1" fi -echo -e "\n" -echo "Push complete, associated $auth_workspace_name with a WebSSH_plugin plugin. Test and validate." -echo -e "\n" +echo -e "\nšŸ‘ Push complete šŸ‘\n" diff --git a/scripts/util.sh b/scripts/util.sh index 7fdb206..3029a27 100755 --- a/scripts/util.sh +++ b/scripts/util.sh @@ -1,6 +1,19 @@ #!/bin/bash # Utility functions / scripts +echoNotice () { echo -e -n "\n$@... "; } + +fgLtRed=$(tput bold;tput setaf 1) +fgLtGrn=$(tput bold;tput setaf 2) +fgLtYel=$(tput bold;tput setaf 3) +fgLtBlu=$(tput bold;tput setaf 4) +fgLtMag=$(tput bold;tput setaf 5) +fgLtCya=$(tput bold;tput setaf 6) +fgLtWhi=$(tput bold;tput setaf 7) +fgLtGry=$(tput bold;tput setaf 8) + +echo ${fgLtWhi} + # check for jq and try to install... output=$(which jq 2>&1) if [[ $? -ne 0 ]]; then @@ -27,4 +40,35 @@ if [[ $? -ne 0 ]]; then exit 255 fi fi -fi \ No newline at end of file +fi + +# checks the output of a command to get the status and report/handle failure +checkOutput() { + if [ $result -eq 0 ]; then + # success + #echo "${fgLtGrn}[OK]${fgLtWhi}" + echo "āœ…" + return + else + # failure + tput bel;tput bel;tput bel;tput bel + #echo "${fgLtRed}[FAILED]${fgLtWhi}" + echo "āŒ" + echo -e "\nPrevious command failed in ${script_path}/${scriptname} with error level: ${result}" + echo -e "\nCommand:\n" + echo " ${command}" + echo -e "\nSTDOUT/STDERR:\n" + echo ${output} + exit 255 + fi +} + +# run a comand and check call checkOutput +runCommand() { + # $1 command + command=$@ + output=$((eval $command) 2>&1) + result="$?" 2>&1 + prevline=$(($LINENO-2)) + checkOutput +} \ No newline at end of file diff --git a/testing/BIG-IP-13.1.0.2-ILX-webssh2-0.2.3.tgz b/testing/BIG-IP-13.1.0.2-ILX-webssh2-0.2.3.tgz deleted file mode 100644 index b463679..0000000 Binary files a/testing/BIG-IP-13.1.0.2-ILX-webssh2-0.2.3.tgz and /dev/null differ diff --git a/workspace/extensions/webssh2/config.json.sample b/workspace/extensions/webssh2/config.json.sample index 90e1214..a90f18b 100644 --- a/workspace/extensions/webssh2/config.json.sample +++ b/workspace/extensions/webssh2/config.json.sample @@ -1,6 +1,6 @@ { "listen": { - "ip": "0.0.0.0", + "ip": "127.0.0.1", "port": 2222 }, "user": { diff --git a/workspace/extensions/webssh2/server/app.js b/workspace/extensions/webssh2/server/app.js index 939618b..f7b5676 100644 --- a/workspace/extensions/webssh2/server/app.js +++ b/workspace/extensions/webssh2/server/app.js @@ -13,7 +13,7 @@ var logger = require('morgan') // sane defaults if config.json or parts are missing let config = { 'listen': { - 'ip': '0.0.0.0', + 'ip': '127.0.0.1', 'port': 2222 }, 'user': {