Skip to content

Commit

Permalink
Add option to download binary w/o installing
Browse files Browse the repository at this point in the history
  • Loading branch information
Piccirello committed Aug 10, 2020
1 parent 2368690 commit f15b526
Showing 1 changed file with 40 additions and 15 deletions.
55 changes: 40 additions & 15 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

DEBUG=0
INSTALL=1
CLEAN_EXIT=0
CWD="$(pwd)"
tempdir=""
Expand All @@ -14,7 +15,7 @@ cleanup() {
echo "ERROR: script failed during execution"

if [ "$DEBUG" -eq 0 ]; then
echo "For more verbose output, re-run this script with the debug arg (./install.sh debug)"
echo "For more verbose output, re-run this script with the debug flag (./install.sh --debug)"
fi
fi

Expand Down Expand Up @@ -43,10 +44,14 @@ delete_tempdir() {
tempdir=""
}

if [ "$1" = "debug" ]; then
if [ "$1" = "--debug" ] || [ "$2" = "--debug" ]; then
DEBUG=1
fi

if [ "$1" = "--no-install" ] || [ "$2" = "--no-install" ]; then
INSTALL=0
fi

# identify OS
os="unknown"
uname_os=$(uname -s)
Expand Down Expand Up @@ -165,16 +170,26 @@ if [ "$format" = "deb" ]; then
mv -f "$filename" "$filename.deb"
filename="$filename.deb"

echo 'Installing...'
dpkg -i "$filename"
echo "Installed Doppler CLI $(doppler -v)"
if [ "$INSTALL" -eq 1 ]; then
echo 'Installing...'
dpkg -i "$filename"
echo "Installed Doppler CLI $(doppler -v)"
else
log_debug "Moving installer to $(pwd) (cwd)"
mv -f "$filename" .
fi
elif [ "$format" = "rpm" ]; then
mv -f "$filename" "$filename.rpm"
filename="$filename.rpm"

echo 'Installing...'
rpm -i --force "$filename"
echo "Installed Doppler CLI $(doppler -v)"
if [ "$INSTALL" -eq 1 ]; then
echo 'Installing...'
rpm -i --force "$filename"
echo "Installed Doppler CLI $(doppler -v)"
else
log_debug "Moving installer to $(pwd) (cwd)"
mv -f "$filename" .
fi
elif [ "$format" = "tar" ]; then
mv -f "$filename" "$filename.tar.gz"
filename="$filename.tar.gz"
Expand All @@ -190,14 +205,24 @@ elif [ "$format" = "tar" ]; then
chmod 755 "$extract_dir/doppler"

# install
echo 'Installing...'
log_debug "Moving binary to /usr/local/bin"
mv -f "$extract_dir/doppler" /usr/local/bin
if [ ! -x "$(command -v doppler)" ]; then
log_debug "Binary not in PATH, moving to /usr/bin"
mv -f /usr/local/bin/doppler /usr/bin/doppler
if [ "$INSTALL" -eq 1 ]; then
echo 'Installing...'
log_debug "Moving binary to /usr/local/bin"
mv -f "$extract_dir/doppler" /usr/local/bin
if [ ! -x "$(command -v doppler)" ]; then
log_debug "Binary not in PATH, moving to /usr/bin"
mv -f /usr/local/bin/doppler /usr/bin/doppler
fi
else
log_debug "Moving binary to $(pwd) (cwd)"
mv -f "$extract_dir/doppler" .
fi

delete_tempdir
echo "Installed Doppler CLI $(doppler -v)"

if [ "$INSTALL" -eq 1 ]; then
echo "Installed Doppler CLI $(doppler -v)"
else
echo "Doppler CLI saved to ./doppler"
fi
fi

0 comments on commit f15b526

Please sign in to comment.