Skip to content

Instantly share code, notes, and snippets.

@poetaman
Last active January 20, 2024 19:44
Show Gist options
  • Save poetaman/bdc598ee607e9767fe33da50e993c650 to your computer and use it in GitHub Desktop.
Save poetaman/bdc598ee607e9767fe33da50e993c650 to your computer and use it in GitHub Desktop.
arttime's simple online installer
#!/usr/bin/env zsh
autoload -Uz is-at-least
if ! is-at-least "5.7"; then
echo "Error: your zsh version $ZSH_VERSION is less than the required version: 5.7"
exit 1
fi
tmpdir=""
dirstatus=1
if command -v mktemp &>/dev/null; then
tmpdir=$(mktemp -d)
if [[ $? == 0 && -d $tmpdir && -w $tmpdir ]]; then
dirstatus=0
fi
fi
if [[ $dirstatus == 1 ]]; then
tmpdir=$HOME/.local/state/arttime/installer
mkdir -p $tmpdir
fi
trap "/bin/rm -rf $tmpdir" EXIT TERM HUP QUIT INT
cd $tmpdir
machine="$(uname -s)"
if [[ $machine =~ ^Darwin.*$ ]]; then
if command -v git &>/dev/null && xcode-select -p &>/dev/null; then
usegit="1"
else
usegit="0"
fi
else
if command -v git &>/dev/null; then
usegit="1"
else
usegit="0"
fi
fi
if [[ $usegit == "1" ]]; then
if [[ ! -d "arttime" ]]; then
echo "Downloading arttime's git repository..."
git clone https://github.com/poetaman/arttime.git
fi
cd arttime
if git rev-parse --is-inside-work-tree &>/dev/null; then
echo "Downloading latest arttime assets..."
git pull
if [[ "$?" != "0" ]]; then
echo "Note: git pull failed in $PWD, try resolving merge conflicts before trying again."
exit 1
fi
else
echo "Note: $PWD is not a git repository, nothing will be updated"
fi
else
echo "Note: git not found. Trying curl or wget to download arttime's git archive."
if command -v curl &>/dev/null; then
downloader="curl -L -O"
elif command -v wget &>/dev/null; then
downloader="wget"
else
echo "Error: neither curl nor wget found. Install git or curl or wget before trying again."
exit 1
fi
if command -v tar &>/dev/null; then
echo "Downloading latest arttime assets..."
$(printf $downloader) https://github.com/poetaman/arttime/archive/main.tar.gz
tar xvf main.tar.gz && command rm main.tar.gz &>/dev/null
elif command -v unzip &>/dev/null; then
echo "Downloading latest arttime assets..."
$(printf $downloader) https://github.com/poetaman/arttime/archive/main.zip
unzip main.zip && command rm main.zip &>/dev/null
else
echo "Error: neither tar nor unzip found. Install tar or unzip before trying again."
exit 1
fi
/bin/rm -rf arttime-notgit 2>/dev/null
mv arttime-main arttime-notgit
cd arttime-notgit
newlinestr="\n "
echo "NOTE: This is not a git repository. DON'T use this directory for development.${newlinestr} Contents of this directory will be overriten if online installer is run${newlinestr} again (with no git installed on system). For development either do a git${newlinestr} clone or rename this directory before using. This directory was left${newlinestr} here only for you to see what files were installed to your system from${newlinestr} matching standard directory paths in this directory." >README_FIRST.txt
fi
./install.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment