Started working on the general installer script
This commit is contained in:
parent
7032b4974c
commit
c5f639f772
70
setup_cswpilib.sh
Normal file
70
setup_cswpilib.sh
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
HELP() {
|
||||||
|
echo "----------------------------------------------------------"
|
||||||
|
echo "setup_cswpilib.sh [options] WPILIB_DL_URL"
|
||||||
|
echo "Install and setup code-server for WPILIB use"
|
||||||
|
echo "This script needs to be run as root!"
|
||||||
|
echo "Options:"
|
||||||
|
echo "\t-h: Show this help"
|
||||||
|
echo "\t-v: Make the script tell you more about what it is doing"
|
||||||
|
echo "----------------------------------------------------------"
|
||||||
|
echo ""
|
||||||
|
}
|
||||||
|
|
||||||
|
VERBOSE=false
|
||||||
|
|
||||||
|
while getopts "hv" flag; do
|
||||||
|
case "$flag" in
|
||||||
|
h)
|
||||||
|
Help
|
||||||
|
exit 0;;
|
||||||
|
v) VERBOSE=true;;
|
||||||
|
\?)
|
||||||
|
echo "Unknown option $flag, run setup_cswpilib.sh -h"
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
WPILIB_DL_URL = ${@:$OPTIND:1}
|
||||||
|
|
||||||
|
if [ $WPILIB_DL_URL == '' ]; then
|
||||||
|
echo "You need to specify a WPILIB download URL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $(whoami) != 'root' ]; then
|
||||||
|
echo "This script must be run as root"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing code-server"
|
||||||
|
|
||||||
|
curl -fsSL https://code-server.dev/install.sh | sh
|
||||||
|
|
||||||
|
echo "Downloading WPILIB"
|
||||||
|
|
||||||
|
WPILIB_FILE_NAME="$(echo "$WPILIB_DL_URL" | grep -o '[^/]*$')"
|
||||||
|
|
||||||
|
curl -fsSL $WPILIB_DL_URL -o "/tmp/$WPILIB_FILE_NAME"
|
||||||
|
|
||||||
|
echo "Unpacking WPILIB"
|
||||||
|
|
||||||
|
tar -xzf "/tmp/$WPILIB_FILE_NAME" -C "/tmp"
|
||||||
|
|
||||||
|
echo "Unpacking WPILIB-artifacts"
|
||||||
|
|
||||||
|
WPILIB_ARTIFACTS=$(find /tmp -type f -name "WPILib_Linux-*-artifacts.tar.gz" -print)
|
||||||
|
|
||||||
|
if [ ! -d "/opt/wpilib" ]; then
|
||||||
|
mkdir -p /opt/wpilib
|
||||||
|
fi
|
||||||
|
|
||||||
|
tar -xzf "$WPILIB_ARTIFACTS" -C "/opt/wpilib"
|
||||||
|
|
||||||
|
find /tmp -type f -name "WPILibInstallerVersion.txt" -exec cp {} /opt/wpilib \;
|
||||||
|
|
||||||
|
echo "Cleanup excess WPILIB files"
|
||||||
|
|
||||||
|
rm -f /tmp/$WPILIB_FILE_NAME
|
||||||
|
rm -rf "$(find /tmp -type d -name "WPILib_Linux-*" -print)"
|
@ -120,4 +120,6 @@ for EXTENSION in $HOMEDIR/wpilib/$ARTIFACTSYEAR/vsCodeExtensions/*.vsix; do
|
|||||||
su -c "code-server --install-extension $EXTENSION" "$USERNAME"
|
su -c "code-server --install-extension $EXTENSION" "$USERNAME"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "$USERNAME is configured, there password is $NEW_PASS"
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user