#!/bin/bash set -e if [ "$#" -ne 1 ] then echo "Usage: $0 USER" exit 1 fi pacman -S --needed zsh git zip unzip bzip2 curl wget vim pwgen if id "$1" &>/dev/null then echo "user $1 found" else echo "create user $1" useradd -m -d /home/$1 -s /bin/zsh $1 fi echo 'reset password' passwd -l $1 echo "$1:$(pwgen 32 1)" | chpasswd echo 'setup nginx' export WORKSPACE=/srv/http/$1 if [ ! -d $WORKSPACE/htdocs ] then mkdir -p $WORKSPACE/htdocs chown $1:$1 $WORKSPACE/htdocs fi if [ ! -d $WORKSPACE/logs ] then mkdir -p $WORKSPACE/logs chown http:http $WORKSPACE/logs fi if [ ! -d $WORKSPACE/tmp ] then mkdir -p /workspace/tmp/$1 chown $1:$1 /workspace/tmp/$1 fi if [ ! -d $WORKSPACE/dashboard ] then mkdir -p /workspace/dashboard/$1 chown $1:$1 /workspace/dashboard/$1 fi if [ ! -f $WORKSPACE/nginx.conf ] then # https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names cat > $WORKSPACE/nginx.conf <