Last active
September 17, 2022 15:33
-
-
Save eru123/aaa55636a2108e2285f91c4c8f329ca5 to your computer and use it in GitHub Desktop.
Dokku Installer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Skidd PH VPS Dokku Setup Script | |
# Tested on Ubuntu 22.04 LTS InterServer VPS | |
# 1 core, 2GB RAM, 30GB SSD | |
DOMAIN="skiddph.com" | |
SUBDOMAIN="www.skiddph.com" | |
ADMIN_EMAIL="yeoligoakino@gmail.com" | |
CURRENT_USER=$(whoami) | |
echo "Your current user is: $USER" | |
# Ensure that the script is run as root | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
# User must be root | |
if [ "$USER" != "root" ]; then | |
echo "You must be root to run this script." | |
exit 1 | |
fi | |
# check if skphfr.txt exists | |
if [ ! -f skphfr.txt ]; then | |
# Update the system | |
apt update && apt upgrade -y | |
# Install the required packages | |
apt install -y git python3 python3-pip python3-venv htop nano curl certbot python3-certbot-nginx | |
certbot --nginx -n -d $DOMAIN -d $SUBDOMAIN -m $ADMIN_EMAIL --agree-tos | |
# Create skphfr.txt | |
touch skphfr.txt | |
fi | |
# Check if apache2 is is running | |
if pgrep -x "apache2" > /dev/null | |
then | |
systemctl stop apache2 | |
systemctl disable apache2 | |
fi | |
# Check if nginx is installed | |
if [ ! -x "$(command -v nginx)" ]; then | |
echo "Installing Nginx" | |
apt install -y nginx | |
# start and enable the nginx service | |
systemctl enable nginx | |
systemctl start nginx | |
fi | |
# Get IP address | |
IP=$(curl -s ifconfig.me) | |
echo "Your IP address is: $IP" | |
# Get latest version of dokku | |
VERSION=$(curl -s https://api.github.com/repos/dokku/dokku/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")') | |
echo "Latest version of dokku is: $VERSION" | |
# Check if dokku is installed | |
if [ -x "$(command -v dokku)" ]; then | |
echo "Dokku is already installed" | |
else | |
echo "Installing Dokku" | |
wget https://raw.githubusercontent.com/dokku/dokku/$VERSION/bootstrap.sh | |
DOKKU_TAG=$VERSION bash bootstrap.sh | |
dokku domains:set-global $DOMAIN | |
ssh-keygen -t rsa -q -f "$HOME/.ssh/id_rsa" -N "" | |
cat "$HOME/.ssh/id_rsa.pub" | dokku ssh-keys:add admin | |
# Core Plugins | |
dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git | |
# dokku plugin:install https://github.com/dokku/dokku-http-auth.git | |
# dokku plugin:install https://github.com/dokku/dokku-redirect.git | |
# dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres | |
# dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql | |
# dokku plugin:install https://github.com/dokku/dokku-mongo.git mongo | |
# dokku plugin:install https://github.com/dokku/dokku-redis.git redis | |
# dokku plugin:install https://github.com/dokku/dokku-memcached.git memcached | |
# dokku plugin:install https://github.com/dokku/dokku-mariadb.git mariadb | |
# dokku plugin:install https://github.com/dokku/dokku-clickhouse.git clickhouse | |
# dokku plugin:install https://github.com/dokku/dokku-couchdb.git couchdb | |
# dokku plugin:install https://github.com/dokku/dokku-rethinkdb.git rethinkdb | |
# dokku plugin:install https://github.com/dokku/dokku-maintenance.git maintenance | |
# dokku plugin:install https://github.com/dokku/dokku-pushpin.git pushpin | |
# dokku plugin:install https://github.com/dokku/dokku-rabbitmq.git rabbitmq | |
# dokku plugin:install https://github.com/dokku/dokku-graphite.git graphite | |
# Community Plugins | |
#dokku plugin:install https://github.com/d1ceward/dokku-posteio.git | |
#dokku posteio:set-domain $DOMAIN | |
#dokku posteio:start | |
fi | |
echo "\n----------------------------\nDNS Setup\n----------------------------" | |
echo "Record | Host" | |
echo "A | *.$DOMAIN -> $IP\n----------------------------" | |
# wget https://gist.githubusercontent.com/eru123/aaa55636a2108e2285f91c4c8f329ca5/raw && sh ./raw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment