diff --git a/roles/daemontools/files/ffhb-setup-service b/roles/daemontools/files/ffhb-setup-service deleted file mode 100644 index bb6989a2..00000000 --- a/roles/daemontools/files/ffhb-setup-service +++ /dev/null @@ -1,151 +0,0 @@ -#! /usr/bin/env bash -######################################################################## -# -# 2014-08 -# Moritz Kaspar Rudert (mortzu) -# mr@planetcyborg.de -# -# 2011-03-03 -# Jonas Pasche -# jpasche@jonaspasche.com -# -######################################################################## -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -######################################################################## -# -# This script sets up a service in your personal ~/.config/service directory -# -######################################################################## - -# Set path to defaults -PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - -# Get prefix of script -SCRIPT_PREFIX="$(awk -F- '{ print $1 }' <<<$(basename $0))" - -usage() { - echo "Usage: $0 [ ...]" - echo "for example: $0 mydaemon ~/bin/daemon" - exit 1 -} - -SERVICENAME=$1 -shift - -if [ -z "$(egrep '^[a-z]' <<< "$SERVICENAME")" ]; then - usage -fi - -TESTCOMMAND=$1 -shift - -if [ -z "$TESTCOMMAND" ]; then - usage -fi - -COMMAND="$(which $TESTCOMMAND 2>/dev/null)" - -if [ -z "$COMMAND" ]; then - echo "The given command $TESTCOMMAND could not be found" >&2 - exit 1 -fi - -if [ ! -d "$HOME/.config/service" ] ; then - echo "You don't seem to have a ~/.config/service directory. Did you execute ${SCRIPT_PREFIX}-setup-svscan before?" >&2 - exit 2 -fi - -for DIR in "$HOME/.config/etc/run-$SERVICENAME" "$HOME/.config/service/$SERVICENAME"; do - if [ -d "$DIR" ]; then - echo "The $DIR directory already exists" >&2 - exit 2 - fi -done - -if [ ! -x "$COMMAND" ]; then - echo "Cannot find the command $COMMAND or it isn't executable" >&2 - exit 3 -fi - -echo "Creating the ~/.config/etc/run-$SERVICENAME/run service run script" >&2 -mkdir -p "$HOME/.config/etc/run-$SERVICENAME" -cat <<__EOF__ > "$HOME/.config/etc/run-$SERVICENAME/run" -#! /usr/bin/env bash - -# These environment variables are sometimes needed by the running daemons -export USER=$USER -export HOME=$HOME - -# Include the user-specific profile, it's actually called .profile on debian. -. \$HOME/.profile - -# Now let's go! -exec $COMMAND $@ 2>&1 -__EOF__ -chmod +x "$HOME/.config/etc/run-$SERVICENAME/run" - -echo "Creating the ~/.config/etc/run-$SERVICENAME/log/run logging run script" -mkdir -p "$HOME/.config/etc/run-$SERVICENAME/log" -cat <<__EOF__ > "$HOME/.config/etc/run-$SERVICENAME/log/run" -#! /usr/bin/env bash -exec multilog t ./main -__EOF__ -chmod +x "$HOME/.config/etc/run-$SERVICENAME/log/run" - -echo "Symlinking ~/.config/etc/run-$SERVICENAME to ~/.config/service/$SERVICENAME to start the service" -ln -s ../etc/run-$SERVICENAME "$HOME/.config/service/$SERVICENAME" - -WAIT=0 -echo -n "Waiting for the service to start ..." -while [ $WAIT -lt 7 ]; do - WAIT=$(($WAIT+1)) - echo -n " $WAIT" - if svok "$HOME/.config/service/$SERVICENAME"; then - break - fi - sleep 1 -done - -if ! svok "$HOME/.config/service/$SERVICENAME" 2>/dev/null; then - echo " failed :-(" >&2 - echo "We're really sorry; this shouldn't have happened." >&2 - exit 4 -fi - -echo " started!" - -# final information -cat <. -# -######################################################################## -# -# This script sets up a personal ~/.config/service directory for svscan -# -######################################################################## - -# Set path to defaults -PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - -if [ "$(id -nu)" = 'root' ]; then - if [ -z "${SUDO_USER}" ]; then - echo 'This script is intended to be run by sudo!' >&2 - exit 1 - fi - - # Confirm that there aren't any bad characters in the username - # w00t for some reason, usernames are to be only 7 chars long. Increasing to 10 - if ! grep -q -E '^[a-z0-9-]{0,32}$' <<< "${SUDO_USER}"; then - echo 'SUDO_USER does not contain a valid username!' >&2 - exit 2 - fi - - if [ ! -d /etc/service ]; then - echo '/etc/service does not exist!' >&2 - mkdir -p /etc/service - fi - - # This is the user's ~/service directory ("eval echo" is needed for tilde expansion) - SERVICE_DIR="$(eval echo ~${SUDO_USER}/.config/service)" - - # Check if we already have some job running here - for DIR in "/etc/service/svscan-${SUDO_USER}" "/etc/run-svscan-${SUDO_USER}"; do - if [ -d "$DIR" ]; then - echo "The $DIR directory already exists!" >&2 - exit 4 - fi - done - - echo "Creating the /etc/run-svscan-${SUDO_USER}/run script" - mkdir -p "/etc/run-svscan-${SUDO_USER}" - cat <<__EOF__ > "/etc/run-svscan-${SUDO_USER}/run" -#! /usr/bin/env bash -ulimit -u 300 -exec setuidgid ${SUDO_USER} /usr/bin/svscan ${SERVICE_DIR} 2>&1 -__EOF__ - chmod 755 "/etc/run-svscan-${SUDO_USER}/run" - - echo "Symlinking /etc/run-svscan-${SUDO_USER} to /etc/service/svscan-${SUDO_USER} to start the service" - ln -s "/etc/run-svscan-${SUDO_USER}" "/etc/service/svscan-${SUDO_USER}" - - WAIT=0 - echo -n 'Waiting for the service to start ...' - while [ $WAIT -lt 7 ]; do - WAIT=$(($WAIT+1)) - echo -n " $WAIT" - if svok "/etc/service/svscan-${SUDO_USER}"; then - break - fi - sleep 1 - done - - if ! svok "/etc/service/svscan-${SUDO_USER}" 2>/dev/null; then - echo ' failed :-(' >&2 - echo "We're really sorry; this shouldn't have happened." >&2 - exit 4 - fi - - echo ' started!' - - # Final information - echo - echo 'Congratulations - your personal ~/.config/service directory is now ready to use!' - echo -else - if [ -d "$HOME/.config/service" ] ; then - echo 'You already have a ~/.config/service directory' >&2 - exit 2 - fi - - mkdir -p "$HOME/.config/etc" "$HOME/.config/service" - - # -n prevents from asking for a password if /etc/sudoers isn't configured correctly yet - exec sudo -n $(readlink -nf $0) -fi diff --git a/roles/daemontools/files/sudo-utils b/roles/daemontools/files/sudo-utils deleted file mode 100644 index fbbfe549..00000000 --- a/roles/daemontools/files/sudo-utils +++ /dev/null @@ -1 +0,0 @@ -%webusers ALL=(root) NOPASSWD: /usr/local/bin/ffhb-setup-svscan diff --git a/roles/daemontools/meta/main.yml b/roles/daemontools/meta/main.yml deleted file mode 100644 index c51530ad..00000000 --- a/roles/daemontools/meta/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -dependencies: - - group-webusers - - sudo diff --git a/roles/daemontools/tasks/main.yml b/roles/daemontools/tasks/main.yml deleted file mode 100644 index 71c67881..00000000 --- a/roles/daemontools/tasks/main.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- name: Install dependencies - apt: - name: - - bc - - daemontools - - daemontools-run - -- name: Install scripts - copy: - src: "{{ item }}" - dest: "/usr/local/bin/{{ item }}" - mode: 0755 - owner: root - group: root - with_items: - - ffhb-setup-service - - ffhb-setup-svscan - -- name: Installing sudoers file - copy: - src: sudo-utils - dest: /etc/sudoers.d/utils - mode: 0440