Advertisement
Guest User

Untitled

a guest
Oct 5th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ ! -f /etc/os-release ]; then
  4. echo This script is only for use with Ubuntu and Debian systems.
  5. exit 1
  6. fi
  7.  
  8. source /etc/os-release
  9.  
  10. echo
  11. echo AMP QuickStart installation script for Ubuntu 16.04+ and Debian 8+
  12. echo This installer will create a default AMP management instance, listening on port 8080 that will start automatically on boot.
  13. echo press CTRL+C to cancel installation.
  14. echo
  15.  
  16. if [[ $EUID -ne 0 ]]; then
  17. echo You need root access to run this script! Try putting 'sudo' in front.
  18. exit 2
  19. fi
  20.  
  21. echo Distribution: $ID
  22. echo
  23. echo Enter a password to use with the AMP system user:
  24. read -sp "System Password: " syspass
  25. echo
  26. echo
  27.  
  28. echo Enter new login details for use with AMP \(The password must not be the same as the system password\!\)
  29. read -p "Username: " ampuser
  30. read -sp "Password: " amppass
  31. echo
  32. read -sp "Confirm Password:" amppassconfirm
  33. echo
  34. echo
  35. echo
  36.  
  37. if [ "$syspass" == "$amppass" ]; then
  38. echo The system and AMP passwords cannot be the same. Aborting.
  39. exit 3
  40. fi
  41.  
  42. if [ "$amppass" != "$amppassconfirm" ]; then
  43. echo Confirmation password does not match. Aborting.
  44. exit 4
  45. fi
  46.  
  47. echo Ready to install AMP. Press ENTER to continue or CTRL+C to cancel.
  48.  
  49. read
  50.  
  51. echo
  52. echo Installing AMP.
  53. echo Creating system user...
  54.  
  55. useradd -d /home/AMP -m AMP -s /bin/bash
  56. echo AMP:$syspass | chpasswd
  57.  
  58. echo Installing prerequisites...
  59.  
  60. if [ "$ID" == "debian" ]; then
  61. apt-get install software-properties-common dirmngr apt-transport-https iptables-persistent
  62. else
  63. apt-get install software-properties-common dirmngr apt-transport-https
  64. fi
  65.  
  66. echo Adding repository...
  67. apt-key adv --fetch-keys http://repo.cubecoders.com/archive.key
  68. apt-add-repository "deb http://repo.cubecoders.com/ debian/"
  69. apt update
  70.  
  71. echo Installing instance manager...
  72. apt install -y ampinstmgr --install-suggests
  73.  
  74. echo Adding firewall rules...
  75. if [ "$ID" == "debian" ]; then
  76. iptables -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
  77. iptables-save > /etc/iptables/rules.v4
  78. else
  79. ufw allow from any to any port 8080 proto tcp
  80. fi
  81.  
  82. echo Creating default instance...
  83. su -l AMP -c "ampinstmgr quick $ampuser $amppass;exit"
  84. su -l AMP -c '(crontab -l ; echo "@reboot ampinstmgr -x") | crontab -'
  85.  
  86. echo Installation complete!
  87. echo
  88. 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