Skip to content

Instantly share code, notes, and snippets.

@PranavMaddula
Created November 18, 2018 08:52
Show Gist options
  • Select an option

  • Save PranavMaddula/151c8da2a5172509b5661d47a27c5a38 to your computer and use it in GitHub Desktop.

Select an option

Save PranavMaddula/151c8da2a5172509b5661d47a27c5a38 to your computer and use it in GitHub Desktop.
#!/bin/sh
## This script helps install the parser
##
## It checks if it's already installed
## and removes "old version" files
## It may spit out errors such as
## File does not exist
##
## It also sets the variable for the installation
## Install Variables
REPONAME=piholeparser
REPOOWNER=deathbybandaid
INSTALLPLACE=/etc/"$REPONAME"/
## Update
apt-get update
## Check for whiptail
if which whiptail >/dev/null;
then
:
else
apt-get install -y whiptail
fi
## Check for whiptail
if which git >/dev/null;
then
:
else
apt-get install -y git
fi
## obvious question
if (whiptail --title ""$REPONAME"" --yes-button "yes" --no-button "no" --yesno "Do You want to install "$REPONAME"?" 10 80)
then
git clone --depth 1 https://github.com/"$REPOOWNER"/"$REPONAME".git /etc/"$REPONAME"/
cp /etc/"$REPONAME"/scripts/updaterun"$REPONAME".sh /etc/updaterun"$REPONAME".sh
(crontab -l ; echo "20 0 * * * bash /updaterun"$REPONAME".sh") | crontab -
else
exit
fi
## What version?
cp /etc/"$REPONAME"/scripts/scriptvars/"$REPONAME".var /etc/"$REPONAME".var
if (whiptail --title ""$REPONAME"" --yes-button "Local Only" --no-button "I'll be uploading to Github" --yesno "What Version of "$REPONAME" to install?" 10 80)
then
echo "version=local" | tee --append /etc/"$REPONAME".var
else
echo "version=github" | tee --append /etc/"$REPONAME".var
GITHUBUSERNAME=$(whiptail --inputbox "Github Username" 10 80 "" 3>&1 1>&2 2>&3)
GITHUBPASSWORD=$(whiptail --inputbox "Github Password" 10 80 "" 3>&1 1>&2 2>&3)
GITHUBEMAIL=$(whiptail --inputbox "Github Email Address" 10 80 "" 3>&1 1>&2 2>&3)
echo "GITHUBUSERNAME="$GITHUBUSERNAME"" | tee --append /etc/"$REPONAME".var
echo "GITHUBPASSWORD="$GITHUBPASSWORD"" | tee --append /etc/"$REPONAME".var
echo "GITHUBEMAIL="$GITHUBEMAIL"" | tee --append /etc/"$REPONAME".var
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment