├── .gitignore ├── LICENSE ├── README.md ├── aliases ├── .bash_aliases ├── .env.sample ├── .gitignore ├── .vimrc ├── load.sh └── remove_work_dir.sh ├── bin └── docker-clean.sh ├── firewall └── ufw_basic_ssh.sh └── install ├── README.md ├── docker └── install-docker.sh ├── golang ├── go.sh └── update-go-path.sh ├── init.sh ├── nginx-proxy └── install-proxy.sh ├── server-automation └── install-server-automation.sh ├── swap └── add-swap.sh ├── timezone └── settimezone.sh └── user ├── .env.sample ├── .gitignore ├── README.md └── add.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Evert Ramos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Easy Server :fire: 2 | 3 | Linux scripts to automate simple tasks in new servers! 4 | 5 | ### Requirements 6 | 7 | - git 8 | - apt 9 | - sudo 10 | 11 | ### TODO 12 | 13 | - [ ] Create install script for [CTOP](https://github.com/bcicen/ctop) 14 | - [ ] Check implementation of [NGINX proxy manager](https://nginxproxymanager.com/) 15 | 16 | ### New branch 'main' 17 | 18 | ```bash 19 | git branch -m master main 20 | git fetch origin 21 | git branch -u origin/main main 22 | git remote set-head origin -a 23 | ``` 24 | -------------------------------------------------------------------------------- /aliases/.bash_aliases: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------- 2 | # 3 | # Basic Aliases 4 | # 5 | #--------------------------------------------------------------------- 6 | 7 | # Bash Aliases 8 | alias l='ls -la' 9 | alias df='df -h' 10 | alias apt-get='sudo apt-get' 11 | alias apt='sudo apt-get' 12 | 13 | # Python 14 | alias p='python3.8' 15 | alias p3='python3' 16 | alias p2='python2' 17 | 18 | # Git Aliases 19 | alias gs='git status' 20 | alias ga='git add' 21 | alias gaa='git add --all' 22 | alias gc='git commit -m' 23 | alias gp='git push' 24 | alias gpp='git pull' 25 | alias gpps='git pull --recurse-submodules' 26 | alias gb='git branch' 27 | alias gk='git checkout' 28 | alias gmd='git checkout main && git merge --no-edit dev && git push --force && git checkout dev' 29 | 30 | # Laravel 31 | alias a='php artisan' 32 | 33 | # Docker 34 | alias d='docker' 35 | alias dl='docker ps' 36 | alias sdl='docker ps --format "table {{.Image}}\t{{.Status}}\t{{.Names}}"' 37 | alias pdl='docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"' 38 | alias dla='docker ps -a' 39 | alias dr='docker run' 40 | alias de='docker exec' 41 | alias di='docker images' 42 | alias dv='docker volume' 43 | alias dlv='docker volume ls' 44 | alias dn='docker network' 45 | alias dln='docker network ls' 46 | alias din='docker network inspect' 47 | alias dlo='docker logs' 48 | alias dlf='docker logs -f --tail 50' 49 | 50 | # Docker Swarm 51 | alias dnode='docker node' 52 | alias dlnode='docker node ls' 53 | alias ddserv='docker service' 54 | alias dlserv='docker service ls' 55 | 56 | # Docker Compose 57 | alias docker-compose='docker compose' 58 | alias dc='docker-compose' 59 | alias dcu='docker-compose up -d' 60 | alias dcd='docker-compose down' 61 | alias dcdv='docker-compose down --volume' 62 | 63 | # Docker-Composer wp-cli 64 | alias wp="docker-compose run --rm wpcli" 65 | 66 | # Composer Aliases 67 | if [ -d "$HOME/.composer/vendor/bin" ] ; then 68 | PATH="$HOME/.composer/vendor/bin:$PATH" 69 | fi 70 | 71 | # Kubernetes basics 72 | alias k='kubectl' 73 | alias kg='kubectl get' 74 | alias kgp='kubectl get pods' 75 | alias kga='kubectl get pods --all-namespaces' 76 | alias kgs='kubectl get service' 77 | alias kgn='kubectl get nodes' 78 | alias kgd='kubectl get deployments' 79 | alias kgss='kubectl get secrets' 80 | 81 | alias kd='kubectl describe' 82 | alias kdp='kubectl describe pods' 83 | alias kds='kubectl describe service' 84 | alias kdn='kubectl describe nodes' 85 | alias kdd='kubectl describe deployments' 86 | alias kdss='kubectl describe secrets' 87 | 88 | # Kubernetes config 89 | alias kgc='kubectl config get-contexts' 90 | alias ksc='kubectl config set-context' 91 | alias kuc='kubectl config use-context' 92 | alias kdc='kubectl config delete-context' 93 | 94 | # Kubernetes actions 95 | alias kaf='kubectl apply -f' 96 | 97 | alias kep='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[0].metadata.name}") -- bash' 98 | alias kep2='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[1].metadata.name}") -- bash' 99 | alias kep3='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[2].metadata.name}") -- bash' 100 | alias kep4='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[3].metadata.name}") -- bash' 101 | alias kep5='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[4].metadata.name}") -- bash' 102 | alias kep6='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[5].metadata.name}") -- bash' 103 | alias kep7='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[6].metadata.name}") -- bash' 104 | alias kep8='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[7].metadata.name}") -- bash' 105 | alias kep9='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[8].metadata.name}") -- bash' 106 | alias kep10='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[9].metadata.name}") -- bash' 107 | 108 | alias kepp='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[0].metadata.name}") --container eagendas-p-nginx -- bash' 109 | alias kepp2='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[1].metadata.name}") --container eagendas-p-nginx -- bash' 110 | alias kepp3='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[2].metadata.name}") --container eagendas-p-nginx -- bash' 111 | alias kepp4='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[3].metadata.name}") --container eagendas-p-nginx -- bash' 112 | alias kepp5='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[4].metadata.name}") --container eagendas-p-nginx -- bash' 113 | alias kepp6='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[5].metadata.name}") --container eagendas-p-nginx -- bash' 114 | alias kepp7='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[6].metadata.name}") --container eagendas-p-nginx -- bash' 115 | alias kepp8='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[7].metadata.name}") --container eagendas-p-nginx -- bash' 116 | alias kepp9='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[8].metadata.name}") --container eagendas-p-nginx -- bash' 117 | alias kepp10='kubectl exec -it $(kubectl get pod -o jsonpath="{.items[9].metadata.name}") --container eagendas-p-nginx -- bash' 118 | 119 | alias klc='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[0].metadata.name}") -- ' 120 | alias klc2='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[1].metadata.name}") -- ' 121 | alias klc3='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[2].metadata.name}") -- ' 122 | alias klc4='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[3].metadata.name}") -- ' 123 | alias klc5='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[4].metadata.name}") -- ' 124 | alias klc6='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[5].metadata.name}") -- ' 125 | alias klc7='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[6].metadata.name}") -- ' 126 | alias klc8='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[7].metadata.name}") -- ' 127 | alias klc9='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[8].metadata.name}") -- ' 128 | alias klc10='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[9].metadata.name}") -- ' 129 | 130 | alias klcc='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[0].metadata.name}") -c eagendas-p-nginx -- ' 131 | alias klcc1='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[0].metadata.name}") -c $1 -- ' 132 | alias klcc2='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[1].metadata.name}") -c eagendas-p-nginx -- ' 133 | alias klcc3='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[2].metadata.name}") -c eagendas-p-nginx -- ' 134 | alias klcc4='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[3].metadata.name}") -c eagendas-p-nginx -- ' 135 | alias klcc5='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[4].metadata.name}") -c eagendas-p-nginx -- ' 136 | alias klcc6='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[5].metadata.name}") -c eagendas-p-nginx -- ' 137 | alias klcc7='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[6].metadata.name}") -c eagendas-p-nginx -- ' 138 | alias klcc8='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[7].metadata.name}") -c eagendas-p-nginx -- ' 139 | alias klcc9='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[8].metadata.name}") -c eagendas-p-nginx -- ' 140 | alias klcc10='kubectl logs -f --tail 100 $(kubectl get pod -o jsonpath="{.items[9].metadata.name}") -c eagendas-p-nginx -- ' 141 | 142 | # Scale up and down 143 | alias scup='kubectl scale --replicas=1 $(kubectl get deployment -o name)' 144 | alias scdown='kubectl scale --replicas=0 $(kubectl get deployment -o name)' 145 | 146 | # Kubens 147 | alias kb='kubens' 148 | 149 | # Kubectx 150 | alias kx='kubectx' 151 | 152 | # Flutter basics 153 | alias f='flutter' 154 | alias fc='flutter config' 155 | 156 | # Apps 157 | alias tor='cd ~/Downloads/tor && ./start-tor-browser.desktop && cd -' 158 | alias code='code-insiders' 159 | 160 | # Other Aliases 161 | ALIAS_HOME_BASE_PATH="$HOME/server" 162 | 163 | alias gg='cd $ALIAS_HOME_BASE_PATH' # Basedir 164 | alias ggs='cd $ALIAS_HOME_BASE_PATH/sites' # Sites 165 | alias ggb='cd $ALIAS_HOME_BASE_PATH/backup' # Backup 166 | alias ggp='cd $ALIAS_HOME_BASE_PATH/proxy' # Proxy 167 | alias ggd='cd $ALIAS_HOME_BASE_PATH/dev' # Development 168 | 169 | # Sail 170 | alias sail='bash vendor/bin/sail' 171 | 172 | # Rust 173 | alias c='cargo' 174 | 175 | # Auth 176 | alias auth='auth --cluster $(kubectx -c | cut -f2 -d"@")' 177 | -------------------------------------------------------------------------------- /aliases/.env.sample: -------------------------------------------------------------------------------- 1 | # Sample file for home base script 2 | 3 | WORK_DIRECTORY=/your/work/directory 4 | -------------------------------------------------------------------------------- /aliases/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /aliases/.vimrc: -------------------------------------------------------------------------------- 1 | set tabstop=2 softtabstop=0 expandtab shiftwidth=2 smarttab 2 | 3 | syntax on 4 | 5 | filetype plugin indent on 6 | 7 | " Open file in the last line used in this file 8 | if has("autocmd") 9 | au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif 10 | endif 11 | 12 | -------------------------------------------------------------------------------- /aliases/load.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get Current server Environmet Settings 4 | SCRIPT_PATH="$(dirname "$(readlink -f "$0")" )" 5 | 6 | if [ -e "$SCRIPT_PATH""/.env" ]; then 7 | source "$SCRIPT_PATH""/.env" 8 | 9 | if [ ! -z ${WORK_DIRECTORY+X} ]; then 10 | 11 | # Go to WorkDirectory 12 | /bin/bash remove_work_dir.sh 13 | echo "Adding workdir alias!" 14 | echo "alias gg='cd "$WORK_DIRECTORY"'" >> "$SCRIPT_PATH""/.bash_aliases" " # WORKDIR" 15 | fi 16 | fi 17 | 18 | DATA="$(date '+%Y-%m-%d_%H-%M-%S')" 19 | 20 | # 21 | # Function to Load the SymLink 22 | # 23 | loadsymlink() { 24 | 25 | # Check if symlink exists and remove it 26 | if [ -L "$HOME""/""$1" ]; then 27 | rm "$HOME""/""$1" 28 | fi 29 | 30 | # Check file exists and rename it 31 | if [ -e "$HOME""/""$1" ]; then 32 | if [ -e "$HOME""/""$1"".""$DATA" ]; then 33 | rm "$HOME""/""$1"".""$DATA" 34 | fi 35 | mv $HOME/$1 $HOME/$1.$DATA 36 | fi 37 | 38 | # Create symlink for new bash aliases 39 | ln -s $SCRIPT_PATH/$1 $HOME/$1 40 | } 41 | 42 | # Load aliases 43 | loadsymlink ".bash_aliases" 44 | 45 | echo "Remember to reload your current bash" 46 | 47 | # Load vimrc 48 | loadsymlink ".vimrc" 49 | 50 | 51 | 52 | exit 0 53 | -------------------------------------------------------------------------------- /aliases/remove_work_dir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Remove "workdir" from bash aliases file 4 | sed -i '/WORKDIR/d' ./.bash_aliases 5 | 6 | exit 0 7 | -------------------------------------------------------------------------------- /bin/docker-clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clean Everything in Docker Environment 4 | docker system prune --all 5 | 6 | # Remove all stopped containers 7 | docker rm -v $(docker ps -a -q) 8 | 9 | # Remove all volumes not in use 10 | docker volume rm $(docker volume ls -qf dangling=true) 11 | docker volume ls -qf dangling=true | xargs -r docker volume rm 12 | 13 | # Remove all images not in use 14 | docker rmi $(docker images --filter "dangling=true" -q --no-trunc) 15 | docker rmi -f $(docker images | grep "none" | awk '/ / { print $3 }') 16 | #docker rmi -f $(docker images | awk '/ / { print $3 }') 17 | 18 | exit 0 19 | 20 | -------------------------------------------------------------------------------- /firewall/ufw_basic_ssh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Default policies 4 | sudo ufw default deny incoming 5 | sudo ufw default allow outgoing 6 | 7 | # Allow ssh 8 | #sudo ufw allow ssh 9 | 10 | # Allow ssh on specific port 11 | sudo ufw allow 2222 12 | 13 | # Allow access from specific IP address 14 | #sudo ufw allow from 192.168.0.1 15 | #sudo ufw allow from 192.168.0.1 to any port 22 16 | #sudo ufw allow from 192.168.0.1/24 17 | #sudo ufw allow from 192.168.0.1/24 to any port 22 18 | 19 | # Specify network interface 20 | #sudo ufw allow in on eth0 to any port 80 21 | #sudo ufw allow in on eth1 to any port 3306 22 | 23 | # Deny incomming connections 24 | #sudo ufw deny http 25 | #sudo ufw deny from 192.168.0.1 26 | 27 | # Deny outgoing connections 28 | #sudo ufw deny out 25 29 | 30 | # Show added 31 | sudo ufw show added 32 | 33 | # Enable ufw 34 | sudo ufw enable 35 | 36 | # UFW status 37 | sudo ufw status verbose 38 | 39 | # List rules 40 | #sudo ufw status numbered 41 | 42 | # To delete a rule 43 | #sudo ufw delete 12 44 | #sudo ufw delete allow http 45 | #sudo ufw delete allow 80 46 | 47 | # Disable UFW 48 | #sudo ufw disable 49 | 50 | # Reset UFW 51 | #sudo ufw reset 52 | 53 | 54 | exit 0 55 | 56 | -------------------------------------------------------------------------------- /install/README.md: -------------------------------------------------------------------------------- 1 | # Install scripts 2 | -------------------------------------------------------------------------------- /install/docker/install-docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #--------------------------------------------------------------------------------- 4 | # Installing Docker 5 | #--------------------------------------------------------------------------------- 6 | 7 | # Create temporary folder (will not be deleted) 8 | mkdir -p ./temp && cd temp 9 | 10 | # Get the latest version of get-docker.sh script 11 | curl -fsSL https://get.docker.com -o get-docker.sh 12 | 13 | # Run get-docker (as sudo) 14 | sudo sh get-docker.sh 15 | 16 | # Add current user to group 17 | sudo usermod -aG docker $USER 18 | 19 | #--------------------------------------------------------------------------------- 20 | # Install Docker Compose 21 | #--------------------------------------------------------------------------------- 22 | 23 | # Dependencies 24 | sudo apt install bash-completion 25 | 26 | # Add bash-completion to .bashrc 27 | cat <> ~/.bashrc 28 | if [ -f /etc/bash_completion ]; then 29 | . /etc/bash_completion 30 | fi 31 | EOT 32 | 33 | #--------------------------------------------------------------------------------- 34 | # Check versions 35 | #--------------------------------------------------------------------------------- 36 | docker version 37 | docker compose version 38 | 39 | exit 0 40 | -------------------------------------------------------------------------------- /install/golang/go.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Variables 4 | VERSION=1.11.4 5 | OS=linux 6 | ARCH=amd64 7 | SHA256=fb26c30e6a04ad937bbc657a1b5bba92f80096af1e8ee6da6430c045a8db3a5b 8 | 9 | # Download 10 | wget https://dl.google.com/go/go$VERSION.$OS-$ARCH.tar.gz 11 | 12 | # Checksum 13 | CHECKSUM_DOWNLOADED_FILE=$(sha256sum go$VERSION.$OS-$ARCH.tar.gz | awk '{print $1}') 14 | 15 | if [ ! "$CHECKSUM_DOWNLOADED_FILE" == "$SHA256" ]; then 16 | echo 17 | echo "Checksum does not match... please check your downloaded file!" 18 | echo 19 | fi 20 | 21 | # Extract 22 | sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz 23 | 24 | # Update PATH 25 | export PATH="$PATH:/usr/local/go/bin" 26 | sudo cp update-go-path.sh /etc/profile.d/ 27 | 28 | # Show version 29 | go version 30 | 31 | # Remove instalation file 32 | rm go$VERSION.$OS-$ARCH.tar.gz 33 | 34 | 35 | exit 0 36 | -------------------------------------------------------------------------------- /install/golang/update-go-path.sh: -------------------------------------------------------------------------------- 1 | # shellcheck shell=sh 2 | 3 | # Expand $PATH to include the directory where golang applications go. 4 | go_bin_path="/usr/local/go/bin" 5 | if [ -n "${PATH##*${go_bin_path}}" -a -n "${PATH##*${go_bin_path}:*}" ]; then 6 | export PATH=$PATH:${go_bin_path} 7 | fi 8 | -------------------------------------------------------------------------------- /install/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Update apt Packages 4 | sudo apt-get update 5 | 6 | # Install GIT 7 | sudo apt-get install -y git wget awk tar shasum 8 | 9 | -------------------------------------------------------------------------------- /install/nginx-proxy/install-proxy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NGINX_PROXY_EMAIL_ADDRESS=your.email@example.com 4 | NGINX_PROXY_BASE_PATH=~/server/proxy/ 5 | NGINX_PROXY_AUTOMATION_PATH=compose 6 | NGINX_PROXY_DATA_FILES=data 7 | 8 | # Create nginx-proxy base path if it does not exists 9 | [[ ! -d "$NGINX_PROXY_BASE_PATH" ]] && mkdir -p $NGINX_PROXY_BASE_PATH && echo "The nginx-proxy base path '$NGINX_PROXY_BASE_PATH' was created sucessfuly!" 10 | 11 | # Clone nginx-proxy latest version 12 | cd $NGINX_PROXY_BASE_PATH 13 | git clone --recurse-submodules https://github.com/evertramos/nginx-proxy-automation.git $NGINX_PROXY_AUTOMATION_PATH 14 | cd $NGINX_PROXY_AUTOMATION_PATH 15 | 16 | # Get current IP Address 17 | NET_INTERFACES=( eth0 ens3 ens4) 18 | for i in "${NET_INTERFACES[@]}"; do 19 | NET_IP=$(ip address show $i | grep "inet\b" | head -n 1 | awk '{print $2}' | cut -d/ -f1) 20 | if [[ $NET_IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 21 | break 22 | fi 23 | done 24 | 25 | # If we were able to identify the IP Address we will update the .env file 26 | if [[ ! $NET_IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then 27 | echo "We could not identify your IP Address, please update the .env and restart the nginx-proxy!" 28 | fi 29 | 30 | # Create the nginx-proxy data path 31 | NGINX_NGINX_PROXY_DATA_PATH=${NGINX_PROXY_BASE_PATH%/}/${NGINX_PROXY_DATA_FILES%/} 32 | [[ ! -d "$NGINX_NGINX_PROXY_DATA_PATH" ]] && mkdir -p $NGINX_NGINX_PROXY_DATA_PATH && echo "The nginx-proxy data path '$NGINX_NGINX_PROXY_DATA_PATH' was created sucessfuly!" 33 | 34 | # Start nginx-proxy with basic configuration 35 | cd ${NGINX_PROXY_BASE_PATH%/}/${NGINX_PROXY_AUTOMATION_PATH%/}/bin 36 | ./fresh-start.sh --data-files-location=$NGINX_NGINX_PROXY_DATA_PATH --default-email=$NGINX_PROXY_EMAIL_ADDRESS --ip-address=$NET_IP --skip-docker-image-check --use-nginx-conf-files --update-nginx-template --yes --silent 37 | 38 | exit 0 39 | -------------------------------------------------------------------------------- /install/server-automation/install-server-automation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SERVER_AUTOMATION_BASE_FOLDER="/home/$USER/server/server-automation" 4 | 5 | # Create server-automation base path if it does not exists 6 | [[ ! -d "$SERVER_AUTOMATION_BASE_FOLDER" ]] && mkdir -p $SERVER_AUTOMATION_BASE_FOLDER && echo "The server-automation base path '$SERVER_AUTOMATION_BASE_FOLDER' was created sucessfuly!" 7 | 8 | # Clone server-automation latest version 9 | cd $SERVER_AUTOMATION_BASE_FOLDER 10 | git clone --recurse-submodules https://github.com/evertramos/server-automation.git . 11 | 12 | # @todo - automate the server-automation initial setup 13 | if [ -f "${SERVER_AUTOMATION_BASE_FOLDER}/README.md" ]; then 14 | echo 15 | echo "Success! Please create the .env file from the sample at ${SERVER_AUTOMATION_BASE_FOLDER}, and update at lease the BASE_SERVER_PATH variable." 16 | echo 17 | else 18 | echo 19 | echo "It seems something went wrong... please try to clone server-automation manually, please access:" 20 | echo "https://github.com/evertramos/server-automation" 21 | echo 22 | fi 23 | 24 | exit 0 25 | 26 | -------------------------------------------------------------------------------- /install/swap/add-swap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SWAP_SIZE=1G 4 | SWAP_SIZE=4G 5 | 6 | # Test swap only create if there is no swap... or confirm with the user 7 | sudo swapon --show 8 | 9 | # Allocate file with specified size 10 | sudo fallocate -l $SWAP_SIZE /swapfile 11 | 12 | # Fix swap permissions 13 | sudo chmod 600 /swapfile 14 | 15 | # Create swap particion 16 | sudo mkswap /swapfile 17 | 18 | # Create the swap 19 | sudo swapon /swapfile 20 | 21 | # Save the swap at fstab to load when server restarts 22 | sudo echo "/swapfile swap swap defaults 0 0" >> /etc/fstab 23 | 24 | # Show the swap and memory 25 | sudo swapon --show 26 | sudo free -h 27 | 28 | # Update swappiness [?] 29 | # cat /proc/sys/vm/swappiness 30 | # sudo sysctl vm.swappiness=10 31 | # cat /proc/sys/vm/swappiness 32 | 33 | # In order to make persistent we need to update on /etc/sysctl.conf file 34 | # option vm.swappiness=10 35 | 36 | exit 0 37 | -------------------------------------------------------------------------------- /install/timezone/settimezone.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo dpkg-reconfigure tzdata 4 | 5 | -------------------------------------------------------------------------------- /install/user/.env.sample: -------------------------------------------------------------------------------- 1 | NEW_USER=user_name 2 | USER_GROUPS=sudo,admin,docker 3 | USER_FULL_NAME="Your Name" 4 | -------------------------------------------------------------------------------- /install/user/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /install/user/README.md: -------------------------------------------------------------------------------- 1 | # to be fixed 2 | 3 | ## Digital Ocean 4 | - no need to add sudores, which is broken in do ubuntu image 5 | - keep only the sudo group 6 | - remove sudo from script 7 | 8 | ## Linode 9 | - keep only group sudo when adding user 10 | - remove sudo from script 11 | 12 | -------------------------------------------------------------------------------- /install/user/add.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source .env 4 | 5 | # Create the User 6 | sudo useradd -c "$USER_FULL_NAME" -U -G $USER_GROUPS -m -s /bin/bash $NEW_USER 7 | 8 | # Add New User to Sudoers 9 | sudo -d 'echo "$NEW_USER ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/90-cloud-init-users' 10 | 11 | # Set Password for the new User 12 | echo 13 | echo "Set a new password the user $NEW_USER" 14 | echo 15 | sudo passwd $NEW_USER 16 | 17 | --------------------------------------------------------------------------------