Plusku

by stuartpb
4 deployments · 1 still active · last rev. 2 years ago

Creates a Plushu server with the Plusku App Ecosystem installed.

The SSH key given will be used for both the root and plushu user.

The root password will be removed as soon as the SSH key is added.

Compatible with: Ubuntu 14.04 LTS
						#!/usr/bin/env bash
set -eo pipefail

# Copyright 2014 Stuart P. Bentley.
# This work may be used freely as long as this notice is included.
# The work is provided "as is" without warranty, express or implied.

# Linode StackScript fields
# <UDF name="hostname" label="Hostname" />
# <UDF name="ssh_key" label="SSH key" example="ssh-rsa AAAAB3NzaC1yc2EAAAA..." />

if [[ $EUID != 0 ]]; then
  echo "This setup script must be run as root." >&2
  exit 1
fi

# Initial configuration
printf '%s\n' "$HOSTNAME" >/etc/hostname
mkdir -p /root/.ssh
printf '%s\n' "$SSH_KEY" >>/root/.ssh/authorized_keys

# Delete the root password when we're setting an SSH key
# (Linode forces root passwords, but the SSH key should supersede that)
[[ -n "$SSH_KEY" ]] && passwd -l root

distro=`[[ -f /etc/os-release ]] &&
  sed -n 's/^ID=\(.*\)$/\1/p' /etc/os-release`

case "$distro" in
  arch)
    # update the system
    pacman -Syu --noconfirm

    # Add dependencies
    pacman -S --noconfirm --needed sudo git docker nginx
    systemctl enable docker nginx
    systemctl start docker nginx
    ;;
  ubuntu)
    # Get Docker
    curl -s https://get.docker.io/ubuntu/ | sh

    # Add Nginx PPA
    add-apt-repository -y ppa:nginx/stable

    # Update apt-get lists
    apt-get update

    # Install other dependencies
    apt-get install -y git nginx dnsutils
    ;;
  *)
    echo "This setup script does not support this distro." >&2
    exit 1
    ;;
esac

# Install Plushu
git clone https://github.com/plushu/plushu /home/plushu
bash /home/plushu/install.sh

# Install app ecosystem
plushu plugins:install plusku

# Use the same SSH keys as root for Plushu
printf '%s\n' "$SSH_KEY" >/home/plushu/.ssh/authorized_keys