scripts update

This commit is contained in:
Bill Church 2019-05-13 20:29:19 -04:00
parent 28283ecd9f
commit b7d3ec3152
12 changed files with 187 additions and 38 deletions

Binary file not shown.

View file

@ -0,0 +1 @@
26e5b0c2aa2c3d064b682f327cad337f5f1f5e3a1251845db19c36eeadcb3fd1 ./bin/BIG-IP-13.1.0.8-ILX-WebSSH2-current.tgz

Binary file not shown.

6
env.sh
View file

@ -1,6 +0,0 @@
#!/bin/sh
ilxhost=root@192.168.30.209
workspace_name=webssh2
package_name=BIG-IP-13.1.0.8-ILX-WebSSH2
pua_location=../f5-pua/bin

View file

@ -1,10 +0,0 @@
#!/bin/bash
source env.sh
rsync -e 'ssh -ax' -av --delete --exclude='.DS_Store' --exclude extensions/$workspace_name/node_modules workspace/. $ilxhost:/var/ilx/workspaces/Common/$workspace_name/.
ssh $ilxhost chown -R root.sdm /var/ilx/workspaces/Common/$workspace_name/
ssh $ilxhost chmod -R ug+rwX,o-w /var/ilx/workspaces/Common/$workspace_name/
ssh $ilxhost chmod u+rw,go-w /var/ilx/workspaces/Common/$workspace_name/version
ssh $ilxhost chmod u+rw,go-w /var/ilx/workspaces/Common/$workspace_name/node_version

19
scripts/build.sh Executable file
View file

@ -0,0 +1,19 @@
#!/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
package_version=$(jq -r ".version" workspace/extensions/webssh2/package.json)
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
cp Build/Release/$webssh_package_name-$package_version.tgz $webssh_pua_location/$webssh_package_name-current.tgz
shasum -a 256 $webssh_pua_location/$webssh_package_name-current.tgz > $webssh_pua_location/$webssh_package_name-current.tgz.sha256
find . -name '.DS_Store' -type f -delete

6
scripts/env.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
webssh_ilxhost=root@192.168.30.209
webssh_workspace_name=webssh2
webssh_package_name=BIG-IP-13.1.0.8-ILX-WebSSH2
webssh_pua_location=./bin

42
scripts/pull.sh Executable file
View file

@ -0,0 +1,42 @@
#!/bin/bash
#
# ./scripts/pull.sh
#
# bill@f5.com
#
# 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
PACKAGE_VERSION=$(jq -r ".version" workspace/extensions/webssh2/package.json 2>&1)
webssh_workspace_name=$webssh_workspace_name-$PACKAGE_VERSION
# 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
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
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

86
scripts/push.sh Executable file
View file

@ -0,0 +1,86 @@
#!/bin/bash
#
# ./scripts/push.sh
#
# bill@f5.com
#
# 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"
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
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/.
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/; \
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
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
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 "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)
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
fi
echo -e "\n"
echo "Push complete, associated $auth_workspace_name with a WebSSH_plugin plugin. Test and validate."
echo -e "\n"

View file

@ -1,9 +1,8 @@
#!/bin/bash
## Syncs from BIG-IP and builds a release based on version in extensions/ephemeral_auth/package.json
# Utility functions / scripts
source env.sh
which jq
# check for jq and try to install...
output=$(which jq 2>&1)
if [[ $? -ne 0 ]]; then
echo -e "You need to install jq: https://stedolan.github.io/jq\n"
echo -e "If you have *brew* you can install with:\n"
@ -28,16 +27,4 @@ if [[ $? -ne 0 ]]; then
exit 255
fi
fi
fi
./sync.sh
package_version=$(jq -r ".version" workspace/extensions/$workspace_name/package.json)
ssh $ilxhost /bin/tar czf - -C /var/ilx/workspaces/Common/$workspace_name . > Build/Release/$package_name-$package_version.tgz
cp Build/Release/$package_name-$package_version.tgz $pua_location/$package_name-current.tgz
shasum -a 256 $pua_location/$package_name-current.tgz > $pua_location/$package_name-current.tgz.sha256
find . -name '.DS_Store' -type f -delete
find $pua_location -name '.DS_Store' -type f -delete
fi

29
scripts/ver.sh Executable file
View file

@ -0,0 +1,29 @@
#!/bin/bash
## displays and optionally changes version of product
source ./scripts/env.sh
source ./scripts/util.sh
echo
# get current version of workspace, ask to change or rebuild
webssh_ilx_ver=$(jq -r ".version" ./workspace/extensions/webssh2/package.json 2>&1)
if [[ $? -ne 0 ]]; then exit; echo "error reading ILX irule version";fi
echo "Current version of $webssh_workspace_name is: $webssh_ilx_ver"
echo -n "If you want to change this version, enter it now otherwise press enter to retain: "
read newver
echo
if [[ ("$newver" != "") ]]; then
echo "Updating version of ILX to: $newver"
export newver
jq --arg newver "$newver" '.version = $newver' < ./workspace/extensions/webssh2/package.json > ./workspace/extensions/webssh2/package.json.new
if [[ $? -ne 0 ]]; then exit; echo "error changing version - ilx";fi
mv ./workspace/extensions/webssh2/package.json.new ./workspace/extensions/webssh2/package.json
else
echo "No changes made"
fi

View file

@ -1,5 +0,0 @@
#!/bin/bash
source env.sh
rsync -e 'ssh -ax' -av --exclude extensions/$workspace_name/node_modules $ilxhost:/var/ilx/workspaces/Common/$workspace_name/. workspace/.