2017-06-27 01:57:39 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# Author: Alexander Epstein https://github.com/alexanderepstein
|
2017-07-06 02:19:12 +02:00
|
|
|
currentVersion="1.10.1"
|
2017-07-07 06:18:07 +02:00
|
|
|
declare -a tools=(currency stocks weather crypt movies taste short geo cheat ytview cloudup qrify)
|
2017-06-28 03:47:23 +02:00
|
|
|
|
2017-07-07 02:45:32 +02:00
|
|
|
askInstall()
|
|
|
|
{
|
|
|
|
echo -n "Do you wish to install $1 [Y/n]: "
|
2017-07-04 02:09:22 +02:00
|
|
|
read -r answer
|
|
|
|
if [[ "$answer" == "Y" || "$answer" == "y" ]] ;then
|
2017-07-07 02:45:32 +02:00
|
|
|
cd $1 || return 1
|
2017-07-07 23:06:51 +02:00
|
|
|
echo -n "Installing $1: "
|
|
|
|
chmod a+x $1
|
|
|
|
cp $1 /usr/local/bin > /dev/null 2>&1 || { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; }
|
|
|
|
echo "Success"
|
2017-07-07 02:45:32 +02:00
|
|
|
cd .. || return 1
|
2017-07-04 02:09:22 +02:00
|
|
|
fi
|
2017-07-07 02:45:32 +02:00
|
|
|
}
|
2017-07-04 02:09:22 +02:00
|
|
|
|
2017-07-07 02:45:32 +02:00
|
|
|
updateTool()
|
|
|
|
{
|
|
|
|
if [[ -f /usr/local/bin/$1 ]];then
|
2017-07-07 06:18:07 +02:00
|
|
|
cd $1 || return 1
|
2017-07-07 23:06:51 +02:00
|
|
|
echo -n "Installing $1: "
|
|
|
|
chmod a+x $1
|
|
|
|
cp $1 /usr/local/bin > /dev/null 2>&1 || { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; }
|
|
|
|
echo "Success"
|
2017-07-07 06:18:07 +02:00
|
|
|
cd .. || return 1
|
2017-07-04 15:04:37 +02:00
|
|
|
fi
|
2017-07-07 02:45:32 +02:00
|
|
|
}
|
2017-07-08 08:40:29 +02:00
|
|
|
|
2017-07-07 06:18:07 +02:00
|
|
|
singleInstall()
|
|
|
|
{
|
|
|
|
cd $1 || exit 1
|
2017-07-07 23:06:51 +02:00
|
|
|
echo -n "Installing $1: "
|
|
|
|
chmod a+x $1
|
|
|
|
cp $1 /usr/local/bin > /dev/null 2>&1 || { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; }
|
|
|
|
echo "Success"
|
2017-07-05 19:00:17 +02:00
|
|
|
cd .. || exit 1
|
2017-07-07 06:18:07 +02:00
|
|
|
}
|
|
|
|
|
2017-07-08 08:40:29 +02:00
|
|
|
copyManpage()
|
|
|
|
{
|
|
|
|
cp bash-snippets.1 /usr/local/man/man1 2>&1 || { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; }
|
|
|
|
}
|
|
|
|
|
2017-07-07 06:18:07 +02:00
|
|
|
if [[ $# == 0 ]]; then
|
|
|
|
for tool in "${tools[@]}"
|
|
|
|
do
|
|
|
|
askInstall $tool || exit 1
|
|
|
|
done
|
2017-07-08 08:40:29 +02:00
|
|
|
copyManpage || exit 1
|
2017-06-28 04:24:43 +02:00
|
|
|
elif [[ $1 == "update" ]]; then
|
|
|
|
echo "Updating scripts..."
|
2017-07-07 06:18:07 +02:00
|
|
|
for tool in "${tools[@]}"
|
|
|
|
do
|
|
|
|
updateTool $tool || exit 1
|
|
|
|
done
|
2017-07-08 08:40:29 +02:00
|
|
|
copyManpage || exit 1
|
2017-07-07 06:18:07 +02:00
|
|
|
elif [[ $1 == "all" ]];then
|
|
|
|
for tool in "${tools[@]}"
|
|
|
|
do
|
|
|
|
singleInstall $tool || exit 1
|
|
|
|
done
|
2017-07-08 08:40:29 +02:00
|
|
|
copyManpage || exit 1
|
2017-07-07 06:18:07 +02:00
|
|
|
else
|
|
|
|
singleInstall $1 || exit 1
|
2017-07-08 08:40:29 +02:00
|
|
|
copyManpage || exit 1
|
2017-06-28 03:47:23 +02:00
|
|
|
fi
|
|
|
|
|
2017-07-07 06:18:07 +02:00
|
|
|
|
|
|
|
|
2017-07-05 19:00:17 +02:00
|
|
|
echo -n "( •_•)"
|
|
|
|
sleep .75
|
|
|
|
echo -n -e "\r( •_•)>⌐■-■"
|
|
|
|
sleep .75
|
|
|
|
echo -n -e "\r "
|
|
|
|
echo -e "\r(⌐■_■)"
|
|
|
|
sleep .5
|
2017-06-28 03:47:23 +02:00
|
|
|
echo "Bash Snippets version $currentVersion"
|
|
|
|
echo "https://github.com/alexanderepstein/Bash-Snippets"
|