diff --git a/setup_cswpilib.sh b/setup_cswpilib.sh new file mode 100644 index 0000000..44a3c62 --- /dev/null +++ b/setup_cswpilib.sh @@ -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)" \ No newline at end of file diff --git a/setup_user.sh b/setup_user.sh index e8ee3db..cdb2d2e 100755 --- a/setup_user.sh +++ b/setup_user.sh @@ -120,4 +120,6 @@ for EXTENSION in $HOMEDIR/wpilib/$ARTIFACTSYEAR/vsCodeExtensions/*.vsix; do su -c "code-server --install-extension $EXTENSION" "$USERNAME" done +echo "$USERNAME is configured, there password is $NEW_PASS" + exit 0