Skip to content

Instantly share code, notes, and snippets.

@davidjenni
Created July 22, 2015 06:59
Show Gist options
  • Save davidjenni/e1e33f3b8b93128251df to your computer and use it in GitHub Desktop.
Save davidjenni/e1e33f3b8b93128251df to your computer and use it in GitHub Desktop.
Linode StackScript for Debian with git, SSH, Docker
#!/bin/bash
# Brings up a Linode VPS with Debian kernel with git, SSH, Docker and firewall installed
# <UDF name="sys_hostname" label="System hostname" default="myvps" example="Name of your server, i.e. linode1." />
# <UDF name="user_name" label="User account name" example="This is the account that you will be using to log in." />
# <UDF name="user_password" label="User password" />
# <UDF name="user_sshkey" label="Public Key for user" default="" example="Recommended method of authentication. It is more secure than password log in." />
# fail immediately if cmd fails; unset env variables will fail the script:
set -e
set -u
exec &> /root/stackscript.log
# if [ -f /etc/debian_version ]; then
# fi
source <ssinclude StackScriptID=1>
export DEBIAN_FRONTEND=noninteractive
system_update
MY_IP = system_primary_ip
system_set_hostname $sys_hostname
system_add_host_entry $MY_IP $sys_hostname
function general_tools {
aptitude -y install htop iotop iftop zip mc git-core
}
function add_user_with_sudo {
USERNAME="$1"
USERPASS="$2"
if [ ! -n "$USERNAME" ] || [ ! -n "$USERPASS" ]; then
echo "No new username and/or password entered"
return 1;
fi
adduser "$USERNAME" --disabled-password --gecos ""
echo "$USERNAME:$USERPASS" | chpasswd
apt-get install -y sudo
usermod -aG sudo "$USERNAME"
}
add_user_with_sudo $user_name $user_password
general_tools
goodstuff
restartServices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment