Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 92 lines (74 sloc) 2.588 kb
#!/bin/sh
set -e
# root privileges required
[ "root" != "$USER" ] && echo "root privileges required..." && exec sudo $0 "$@"
# set variables
USER_NAME="www-vibe"
GROUP_NAME="www-vibe"
USER_COMMENT="Vibe user"
CONFIG_FILE="/etc/vibe/vibe.conf"
SYMLINK_FILE="/usr/bin/vibe"
LOG_FILE="/var/spool/vibe/install.log"
# remove user, group, log file and configuration file
if [ "$1" = "-r" ]
then
# remove obsolete "vibe" user/group
/usr/sbin/userdel vibe 2>/dev/null || true
/usr/sbin/groupdel vibe 2>/dev/null || true
# remove user if present in log file
if grep "^user: $USER_NAME$" $LOG_FILE >/dev/null 2>&1
then
/usr/sbin/userdel $USER_NAME >/dev/null 2>&1 && echo "'$USER_NAME' user removed."
sed -i "/^user: $USER_NAME$/d" $LOG_FILE >/dev/null 2>&1
fi
# remove group if present in log file
if grep "^group: $GROUP_NAME$" $LOG_FILE >/dev/null 2>&1
then
/usr/sbin/groupdel $GROUP_NAME >/dev/null 2>&1 && echo "'$GROUP_NAME' group removed."
sed -i "/^group: $GROUP_NAME$/d" $LOG_FILE >/dev/null 2>&1
fi
# remove log file if no data
if [ -f $LOG_FILE ] && [ -z $(tr -d '[ \t\r\n]' 2>/dev/null <$LOG_FILE) ]
then
rm -f $LOG_FILE
rmdir $(dirname $LOG_FILE) >/dev/null 2>&1 || true
fi
# remove config file
echo "Removing configuration file $CONFIG_FILE..."
rm -f $CONFIG_FILE
rmdir $(dirname $CONFIG_FILE) >/dev/null 2>&1 || true
# remove symlink
echo "Removing symlink $SYMLINK_FILE..."
rm -f $SYMLINK_FILE
exit
fi
# create a symlink to the vibe script
echo "Creating symlink in $SYMLINK_FILE..."
ln -sf $(pwd)/bin/vibe $SYMLINK_FILE
# creating group if he isn't already there
if ! getent group $GROUP_NAME >/dev/null; then
echo "Creating group $GROUP_NAME..."
/usr/sbin/groupadd -r $GROUP_NAME >/dev/null
mkdir -p $(dirname $LOG_FILE)
echo "group: $GROUP_NAME" >>$LOG_FILE
fi
# creating user if he isn't already there
if ! getent passwd $USER_NAME >/dev/null; then
echo "Creating user $USER_NAME..."
/usr/sbin/useradd -r -g $GROUP_NAME -c "$USER_COMMENT" $USER_NAME >/dev/null
mkdir -p $(dirname $LOG_FILE)
echo "user: $USER_NAME" >>$LOG_FILE
fi
# create config dir if not there
mkdir -p $(dirname $CONFIG_FILE)
# create/update config file
echo "Creating new config file in $CONFIG_FILE..."
USER_ID=$(getent passwd $USER_NAME | cut -d: -f3)
GROUP_ID=$(getent group $GROUP_NAME | cut -d: -f3)
echo '{
"uid": '$USER_ID',
"gid": '$GROUP_ID'
}' >$CONFIG_FILE
# if everything went fine
echo "Setup finished successfully."
echo "You can now run 'vibe' from any vibe.d application directory to run an app (e.g. in examples/http_server/)."
Jump to Line
Something went wrong with that request. Please try again.