#!/usr/bin/env bash # This script downloads the latest release from `releases` and installs it to root directory. set -e tarball_name="Linux.tar.gz" # tarball_url="https://kriss.run/new/releases/$tarball_name" tarball_url="http://kriss.run/new/releases/Linux.tar.gz" __cleanup() { echo "Removing $tarball_name..." rm -f "$tarball_name" rm -rf Linux } __install() { # Download the latest tarball wget "$tarball_url" -O "$tarball_name" # Check if the download was successful if [ ! -f "$tarball_name" ]; then echo "Failed to download the tarball from $tarball_url" exit 1 fi # Check if the tarball is valid if ! tar -tzf "$tarball_name" > /dev/null 2>&1; then echo "The downloaded tarball is not valid or corrupted." __cleanup exit 1 fi # Extract the tarball to the root directory and verbosely output every file extracted with location echo "Extracting $tarball_name to the $(pwd -P)..." tar -xzvf "$tarball_name" # Check if the extraction was successful if [ $? -ne 0 ]; then echo "Failed to extract the tarball." __cleanup exit 1 fi for dir in Linux/*/; do dirname=$(basename "$dir") echo "Copying contents of ${dir}* to /${dirname}/*..." # Copy contents of each directory to the corresponding root directory if [ -d "/${dirname}" ]; then # rsync -av "$dir" "/" cp -r "${dir}"* "/${dirname}/" else echo "Directory /${dirname} does not exist... Skipping." fi done # Remove the tarball after extraction __cleanup echo "Latest release has been successfully installed to the root directory." } __install