Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ ! -f /etc/os-release ]; then
- echo This script is only for use with Ubuntu and Debian systems.
- exit 1
- fi
- source /etc/os-release
- echo
- echo AMP QuickStart installation script for Ubuntu 16.04+ and Debian 8+
- echo This installer will create a default AMP management instance, listening on port 8080 that will start automatically on boot.
- echo press CTRL+C to cancel installation.
- echo
- if [[ $EUID -ne 0 ]]; then
- echo You need root access to run this script! Try putting 'sudo' in front.
- exit 2
- fi
- echo Distribution: $ID
- echo
- echo Enter a password to use with the AMP system user:
- read -sp "System Password: " syspass
- echo
- echo
- echo Enter new login details for use with AMP \(The password must not be the same as the system password\!\)
- read -p "Username: " ampuser
- read -sp "Password: " amppass
- echo
- read -sp "Confirm Password:" amppassconfirm
- echo
- echo
- echo
- if [ "$syspass" == "$amppass" ]; then
- echo The system and AMP passwords cannot be the same. Aborting.
- exit 3
- fi
- if [ "$amppass" != "$amppassconfirm" ]; then
- echo Confirmation password does not match. Aborting.
- exit 4
- fi
- echo Ready to install AMP. Press ENTER to continue or CTRL+C to cancel.
- read
- echo
- echo Installing AMP.
- echo Creating system user...
- useradd -d /home/AMP -m AMP -s /bin/bash
- echo AMP:$syspass | chpasswd
- echo Installing prerequisites...
- if [ "$ID" == "debian" ]; then
- apt-get install software-properties-common dirmngr apt-transport-https iptables-persistent
- else
- apt-get install software-properties-common dirmngr apt-transport-https
- fi
- echo Adding repository...
- apt-key adv --fetch-keys http://repo.cubecoders.com/archive.key
- apt-add-repository "deb http://repo.cubecoders.com/ debian/"
- apt update
- echo Installing instance manager...
- apt install -y ampinstmgr --install-suggests
- echo Adding firewall rules...
- if [ "$ID" == "debian" ]; then
- iptables -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
- iptables-save > /etc/iptables/rules.v4
- else
- ufw allow from any to any port 8080 proto tcp
- fi
- echo Creating default instance...
- su -l AMP -c "ampinstmgr quick $ampuser $amppass;exit"
- su -l AMP -c '(crontab -l ; echo "@reboot ampinstmgr -x") | crontab -'
- echo Installation complete!
- echo
- echo You can now reach AMP at http://`hostname -I | cut -f 1 -d ' '`:8080/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement