Skip to content

Instantly share code, notes, and snippets.

@brannondorsey
Last active September 24, 2021 07:28
Show Gist options
  • Save brannondorsey/fcdfaec1490e0c5d8ae948481d3dba33 to your computer and use it in GitHub Desktop.
Save brannondorsey/fcdfaec1490e0c5d8ae948481d3dba33 to your computer and use it in GitHub Desktop.
Runway Linux Install Script
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m' # no color
# attempts to download the URL specified as argument $1 using wget. If wget isn't
# installed it falls back to curl. If curl isn't installed it prints an error and
# exits.
# usage: download <url> <outfile>
function download() {
if command -v wget &> /dev/null ; then
echo -e "${GREEN}Downloading $1 using wget...${NC}"
wget -O "$2" "$1"
elif command -v curl &> /dev/null ; then
echo -e "${GREEN}Downloading $1 using curl...${NC}"
curl -l "$1" -o "$2"
else
echo -e "${RED}Neither wget or curl is installed. Please install wget or curl before continuing.${NC}" >> /dev/stderr
exit 1
fi
}
FLAG=$1
function check_prerequisits() {
if [ `whoami` = root ] && [ "$FLAG" != '--force' ]; then
echo -e "${RED}For your security please do not run this script as root. If you must install as root please re-run this script with the --force argument.${NC}" >> /dev/stderr
exit 1
fi
if [ ! -w . ] ; then
echo -e "${RED}This folder is not writable by your user. Please change directories.${NC}" >> /dev/stderr
exit 1
fi
}
function install_appimaged() {
# void if appimaged is already installed
if command -v appimaged &> /dev/null ; then
echo -e "${GREEN}appimaged already installed, skipping install of appimaged${NC}"
return
fi
if [ ! -f .appimaged-x86_64.AppImage ] ; then
download "https://github.com/AppImage/appimaged/releases/download/continuous/appimaged-x86_64.AppImage" .appimaged-x86_64.AppImage
fi
if [ ! -x .appimaged-x86_64.AppImage ] ; then
chmod +x .appimaged-x86_64.AppImage
fi
# this command will clean up after itself so no need to remove the file afterwords
./.appimaged-x86_64.AppImage --install
}
function install_runway() {
if [ ! -f Runway.AppImage ] ; then
download "https://api.runwayml.com/v1/download?platform=linux" Runway.AppImage
fi
if [ ! -x Runway.AppImage ] ; then
chmod +x Runway.AppImage
fi
# if the user owns the directory and its in the user's PATH
if [ -O "$HOME/.local/bin" ] && [[ ":$PATH:" == *":$HOME/.local/bin:"* ]] ; then
echo -e "${GREEN}Installing Runway.AppImage in $HOME/.local/bin/${NC}"
cp Runway.AppImage "$HOME/.local/bin/"
elif [ -O "$HOME/bin" ] && [[ ":$PATH:" == *":$HOME/bin:"* ]] ; then
echo -e "${GREEN}Installing Runway.AppImage in $HOME/bin/${NC}"
cp Runway.AppImage "$HOME/bin/"
elif [ -O "/usr/local/bin" ] && [[ ":$PATH:" == *":/usr/local/bin:"* ]] ; then
echo -e "${GREEN}Installing Runway.AppImage in /usr/local/bin${NC}"
cp Runway.AppImage /usr/local/bin/
else
echo -e "${GREEN}Creating $HOME/.local/bin${NC}"
mkdir -p "$HOME/.local/bin"
echo -e "${GREEN}Installing Runway.AppImage in $HOME/.local/bin/${NC}"
cp Runway.AppImage "$HOME/.local/bin/"
echo -e "${GREEN}Adding $HOME/.local/bin to \$PATH in $HOME/.bashrc${NC}"
echo -e "${GREEN}PATH=$HOME/.local/bin:\$PATH" >> "$HOME/.bashrc${NC}"
echo -e "${GREEN}Sourcing $HOME/.bashrc${NC}"
source "$HOME/.bashrc"
fi
}
check_prerequisits
install_appimaged
install_runway
echo -e "${CYAN}Type \"Runway.AppImage\" and press ENTER to launch. After that you'll be able to save the app to your Dock if you prefer.${NC}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment