Skip to content

Instantly share code, notes, and snippets.

@rehmatworks
Last active August 22, 2017 09:55
Show Gist options
  • Save rehmatworks/9248305f0785c54672bab165a077e169 to your computer and use it in GitHub Desktop.
Save rehmatworks/9248305f0785c54672bab165a077e169 to your computer and use it in GitHub Desktop.
A simple script to easily install token dispenser on an Ubuntu server
#!/bin/bash
################################################################
# A simple script to install Token Dispenser on an Ubuntu server
# Author: Rehmat Alam
# Website: https://supportivehands.net
################################################################
read -p "Gmail ID: " gmailAddress
read -p "Account Password: " accountPassword
read -p "Server's Public IP: " serverIP
if [ -z "$gmailAddress" ]
then
echo -e "\e[31mPlease provide your Gmail email address\e[39m";
exit;
fi
if [ -z "$accountPassword" ]
then
echo -e "\e[31mPlease provide your Google account password\e[39m";
exit;
fi
if [ -z "$serverIP" ]
then
echo -e "\e[31mPlease provide your server's public IP\e[39m";
exit;
fi
echo -e "\e[33mPlease wait, fetching and setting up Token Dispenser from GitHub \e[39m"
cd ~/
echo -e "\e[33mClonning the GitHub repo of Token Dispenser \e[39m"
git clone https://github.com/yeriomin/token-dispenser &>/dev/null;
cd token-dispenser;
echo -e "\e[33mRecreating the configuration file \e[39m"
cp src/main/resources/config.properties src/main/resources/config.properties-bak;
echo "spark-host=$serverIP
spark-port=8085
storage=plaintext
storage-plaintext-path=passwords.txt
enable-email-retrieval=false" > src/main/resources/config.properties;
echo "$gmailAddress $accountPassword" > passwords.txt;
if hash ufw 2>/dev/null;
then
echo -e "\e[33mUpdating firewal rules to allow selected port for token dispenser \e[39m"
ufw allow 8085 2>/dev/null;
sudo service ufw restart;
fi
echo -e "\e[33mInstalling all required dependencies \e[39m"
sudo apt-get -y install software-properties-common 2>/dev/null;
sudo apt-add-repository universe 2>/dev/null;
sudo apt-get -y update 2>/dev/null;
sudo apt-get -y install maven 2>/dev/null;
sudo apt-get -y install openjdk-8-jdk 2>/dev/null;
mvn install 2>/dev/null;
echo -e "\e[33mLaunching the server\e[39m";
echo -e "\e[32mToken should be available at http://$serverIP:8085/token/email/$gmailAddress\e[39m";
echo -e "\e[33mPress CTRL+Z and then enter \e[32mbg\e[33m and then enter \e[32mdisown\e[33m to put the server process to background \e[39m";
java -jar target/token-dispenser.jar 2>/dev/null;
@rehmatworks
Copy link
Author

rehmatworks commented Jul 7, 2017

wget https://gist.githubusercontent.com/rehmatworks/9248305f0785c54672bab165a077e169/raw/09d72505ef847651cf0a5e15a7228801e6948631/tokdis.sh
mv tokdis.sh /usr/local/bin/tokdis
chmod +x /usr/local/bin/tokdis
tokdis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment