Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sean2121/6d264c417b1a8628841fef9f58ed3d41 to your computer and use it in GitHub Desktop.
Save sean2121/6d264c417b1a8628841fef9f58ed3d41 to your computer and use it in GitHub Desktop.
Gyazo-for-Linux install script for Linux Mint rafaela
#!/bin/bash
curl_check ()
{
echo "Checking for curl..."
if command -v curl > /dev/null; then
echo "Detected curl..."
else
echo "Installing curl..."
apt-get install -q -y curl
fi
}
os="ubuntu"
dist="Disco Dingo"
host=
get_hostname ()
{
echo "Getting the hostname of this machine..."
host=`hostname -f 2>/dev/null`
if [ "$host" = "" ]; then
host=`hostname 2>/dev/null`
if [ "$host" = "" ]; then
host=$HOSTNAME
fi
fi
if [ "$host" = "" -o "$host" = "(none)" ]; then
echo "Unable to determine the hostname of your system!"
echo
echo "Please consult the documentation for your system. The files you need "
echo "to modify to do this vary between Linux distribution and version."
echo
exit 1
fi
echo "Found hostname: ${host}"
}
echo "Detected operating system as $os/$dist."
curl_check
echo -n "Installing apt-transport-https... "
# install apt-https-transport
apt-get install -y apt-transport-https &> /dev/null
echo "done."
get_hostname
apt_source_path="/etc/apt/sources.list.d/gyazo_gyazo-for-linux.list"
apt_config_url="https://packagecloud.io/install/repositories/gyazo/gyazo-for-linux/config_file.list?os=${os}&dist=${dist}&name=${host}&source=script"
echo -n "Installing $apt_source_path..."
# create an apt config file for this repository
curl -f "${apt_config_url}" > $apt_source_path
curl_exit_code=$?
if [ "$curl_exit_code" = "22" ]; then
echo -n "Unable to download repo config from: "
echo "${apt_config_url}"
echo
echo "Please contact support@packagecloud.io and report this."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" = "35" ]; then
echo "curl is unable to connect to packagecloud.io over TLS when running: "
echo " curl ${apt_config_url}"
echo "This is usually due to one of two things:"
echo
echo " 1.) Missing CA root certificates (make sure the ca-certificates package is installed)"
echo " 2.) An old version of libssl. Try upgrading libssl on your system to a more recent version"
echo
echo "Contact support@packagecloud.io with information about your system for help."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
elif [ "$curl_exit_code" -gt "0" ]; then
echo
echo "Unable to run: "
echo " curl ${apt_config_url}"
echo
echo "Double check your curl installation and try again."
[ -e $apt_source_path ] && rm $apt_source_path
exit 1
else
echo "done."
fi
echo -n "Importing packagecloud gpg key... "
# import the gpg key
curl https://packagecloud.io/gpg.key 2> /dev/null | apt-key add - &>/dev/null
echo "done."
echo -n "Running apt-get update... "
# update apt on this system
apt-get update &> /dev/null
echo "done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment