Linux Upgrade Script

Product: PowerShell Universal
Version: 5.5.0

If anyone needs it, I modified the Linux install script to create an upgrade script. Just to note, the script excludes the Repository folder as we are synced with Git, and it also changes the port to 50000 since 5000 conflicted with Nutanix guest tools.

@adam If it looks good to you, maybe it could be added to the documentation?

# These are used to derive the download URL
PSU_VERSION="5.5.0" # Change this to the current version
PSU_ARCH="x64" # Change this to your desired architecture
PSU_FILE="Universal.linux-${PSU_ARCH}.${PSU_VERSION}.zip"
PSU_URL="https://imsreleases.blob.core.windows.net/universal/production/${PSU_VERSION}/${PSU_FILE}"

# These are used for installing PowerShell Universal
# If you'd like to use a different path, change this
PSU_PATH="/opt/psuniversal"
PSU_EXEC="${PSU_PATH}/Universal.Server"

# These are for installing it as a service
PSU_SERVICE="psuniversal"
PSU_USER="psuniversal"

BACKUP_DATE=$(date +"%Y%m%d")
BACKUP_FILE="backup-${BACKUP_DATE}.tar.gz"
BACKUP_FILE_PATH="/home/psuniversal/${BACKUP_FILE}"
BACKUP_SOURCE="/home/psuniversal/.PowerShellUniversal"

echo "Stopping PSU"
sudo systemctl stop $PSU_SERVICE

echo "Making backup"
sudo tar -czf $BACKUP_FILE_PATH -C $BACKUP_SOURCE --exclude='./Repository' --transform='s|^\./||' .

echo "Deleting existing installation folder"
sudo rm -rf $PSU_PATH

echo "Creating $PSU_PATH and granting access to $USER"
sudo mkdir $PSU_PATH
sudo setfacl -m "u:${USER}:rwx" $PSU_PATH

echo "Creating user $PSU_USER and making it the owner of $PSU_PATH"
sudo chown $PSU_USER -R $PSU_PATH

echo "Downloading PowerShell Universal $PSU_VERSION ($PSU_ARCH)"
wget -q $PSU_URL -O $PSU_FILE

echo "Extracting $PSU_FILE to $PSU_PATH"
unzip -o -qq $PSU_FILE -d $PSU_PATH

echo "Make $PSU_EXEC executable"
sudo chmod +x $PSU_EXEC

echo "Changing port to 50000"
sudo sed -i 's/*:5000/*:50000/' /opt/psuniversal/appsettings.json

echo "Starting PSU"
sudo systemctl start $PSU_SERVICE
sudo systemctl status $PSU_SERVICE --no-pager