Page MenuHomeDevCentral

No OneTemporary

diff --git a/roles/viperserv/account/init.sls b/roles/viperserv/account/init.sls
index 21e40db..8e78d0d 100644
--- a/roles/viperserv/account/init.sls
+++ b/roles/viperserv/account/init.sls
@@ -1,47 +1,47 @@
# -------------------------------------------------------------
# Salt — Deploy ViperServ (eggdrop)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Created: 2017-11-14
# Description: Eggdrop on Freenode
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
{% from "map.jinja" import dirs with context %}
# -------------------------------------------------------------
# Service accounts
# -------------------------------------------------------------
{% for username, user in pillar['viperserv_accounts'].iteritems() %}
viperserv_account_{{ username }}:
user.present:
- name: {{ username }}
- fullname: {{ user['fullname'] }}
- uid: {{ user['uid'] }}
- gid: nasqueron-irc
- home: /var/run/{{ username }}
/var/run/{{ username }}:
file.directory:
- user: {{ user['uid'] }}
- group: nasqueron-irc
- - dir_mode: 700
+ - dir_mode: 711
{% endfor %}
# -------------------------------------------------------------
# Sudo capabilities
#
# Members of nasqueron-irc should be able to sudo -u viperserv …
# -------------------------------------------------------------
viperserv_sudo_capabilities_file:
file.managed:
- name: {{ dirs.etc }}/sudoers.d/viperserv
- source: salt://roles/viperserv/account/files/viperserv.sudoers
- template: jinja
- context:
accounts: {{ pillar['viperserv_accounts'].keys() }}
bots: {{ pillar['viperserv_bots'].keys() }}
diff --git a/roles/viperserv/eggdrop/files/rc/eggdrop b/roles/viperserv/eggdrop/files/rc/eggdrop
new file mode 100755
index 0000000..4552ae1
--- /dev/null
+++ b/roles/viperserv/eggdrop/files/rc/eggdrop
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+# PROVIDE: eggdrop
+# REQUIRE: mysql
+#
+# Add the following line to /etc/rc.conf to enable mysql:
+# eggdrop_(instance_)?enable (bool): Set to "NO" by default.
+# Set it to "YES" to enable eggdrop.
+# eggdrop_(instance_)?pidfile (str): Custom PID file path and name.
+# Default to "/var/run/${eggdrop_user}/${eggdrop_username}.pid" in lowercase.
+# eggdrop_(instance_)?conf (str): Path to the configuration file
+# Default to "/srv/viperserv(/${instance})/eggdrop.conf"
+# eggdrop_(instance_)?user (str): User to run eggdrop as
+# Default to "viperserv"
+# eggdrop_instances (str): Set to "" by default.
+# If defined, list of instances to enable
+# eggdrop_basedir (str): The working directory of the eggdrop process
+# Default to "/srv/viperserv"
+
+. /etc/rc.subr
+
+name="eggdrop"
+rcvar=eggdrop_enable
+
+load_rc_config $name
+
+: ${eggdrop_enable="NO"}
+: ${eggdrop_user="viperserv"}
+: ${eggdrop_basedir="/srv/viperserv"}
+
+command="/usr/sbin/daemon"
+procname="/usr/local/bin/eggdrop"
+start_precmd="${name}_prestart"
+
+# Instances logic has been forked from the MySQL port rc service code.
+if [ -n "$2" ]; then
+ instance="$2"
+ load_rc_config ${name}_${instance}
+ case "$eggdrop_instances" in
+ "$2 "*|*" $2 "*|*" $2"|"$2")
+ eval eggdrop_user="\${eggdrop_${instance}_user:-\"${eggdrop_user}\"}"
+ eval eggdrop_pidfile="\${eggdrop_${instance}_pidfile:-\"/var/run/${eggdrop_user}/$(echo $instance | awk '{print tolower($0)}').pid\"}"
+ eval eggdrop_conf="\${eggdrop_${instance}_conf:-\"${eggdrop_basedir}/${instance}/eggdrop.conf\"}"
+ eggdrop_name=${instance}
+ ;;
+ *)
+ err 1 "$2 not found in eggdrop_instances" ;;
+ esac
+else
+ if [ -n "${eggdrop_instances}" -a -n "$1" ]; then
+ for instance in ${eggdrop_instances}; do
+ eval _enable="\${eggdrop_${instance}_enable}"
+ case "${_enable:-${eggdrop_enable}}" in
+ [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
+ continue
+ ;;
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ ;;
+ *)
+ if [ -z "$_enable" ]; then
+ _var=eggdrop_enable
+ else
+ _var=eggdrop_${instance}_enable
+ fi
+ warn "Bad value" \
+ "'${_enable:-${eggdrop_enable}}'" \
+ "for ${_var}. " \
+ "Instance ${instance} skipped."
+ continue
+ ;;
+ esac
+ echo "===> eggdrop instance: ${instance}"
+ if /usr/local/etc/rc.d/eggdrop $1 ${instance}; then
+ success="${instance} ${success}"
+ else
+ failed="${instance} (${retcode}) ${failed}"
+ fi
+ done
+ exit 0
+ else
+ eggdrop_pidfile=${eggdrop_pidfile:-"/var/run/eggdrop.pid"}
+ eggdrop_conf=${eggdrop_basedir}/eggdrop.conf
+ eggdrop_name=eggdrop
+ fi
+fi
+
+eggdrop_chdir=${eggdrop_basedir}
+home_directory=$(getent passwd $eggdrop_user | cut -d: -f6)
+eggdrop_env="HOME=$home_directory PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:$home_directory/bin"
+pidfile=$eggdrop_pidfile
+command_args="$eggdrop_conf"
+
+eggdrop_prestart()
+{
+ if [ ! -f "${eggdrop_basedir}/${eggdrop_name}/user" ]; then
+ echo "No userfile for ${eggdrop_name}. Setting option to create one."
+ command_args="${procname} -m $eggdrop_conf"
+ fi
+}
+
+run_rc_command "$1"
diff --git a/roles/viperserv/eggdrop/files/rc/instances b/roles/viperserv/eggdrop/files/rc/instances
new file mode 100644
index 0000000..fc595df
--- /dev/null
+++ b/roles/viperserv/eggdrop/files/rc/instances
@@ -0,0 +1,17 @@
+# -------------------------------------------------------------
+# ViperServ — Deploy eggdrop park
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/viperserv/eggdrop/files/rc/instances
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+eggdrop_enable="YES"
+eggdrop_instances="{{ bots }}"
diff --git a/roles/viperserv/eggdrop/files/rc/per_instance b/roles/viperserv/eggdrop/files/rc/per_instance
new file mode 100644
index 0000000..2a00224
--- /dev/null
+++ b/roles/viperserv/eggdrop/files/rc/per_instance
@@ -0,0 +1,20 @@
+# -------------------------------------------------------------
+# ViperServ — Deploy eggdrop park
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Instance: {{ botname }}
+# License: Trivial work, not eligible to copyright
+# Source file: roles/viperserv/eggdrop/files/rc/per_instance
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+eggdrop_{{ botname }}_enable="YES"
+{% if runas %}
+eggdrop_{{ botname }}_user="{{ runas }}"
+{% endif %}
diff --git a/roles/viperserv/eggdrop/init.sls b/roles/viperserv/eggdrop/init.sls
index 1478b44..9983d07 100644
--- a/roles/viperserv/eggdrop/init.sls
+++ b/roles/viperserv/eggdrop/init.sls
@@ -1,11 +1,12 @@
# -------------------------------------------------------------
# Salt — Deploy eggdrop park
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Created: 2017-11-05
# License: Trivial work, not eligible to copyright
# -------------------------------------------------------------
include:
- .software
- .config
+ - .service
diff --git a/roles/viperserv/eggdrop/service.sls b/roles/viperserv/eggdrop/service.sls
new file mode 100644
index 0000000..c235f97
--- /dev/null
+++ b/roles/viperserv/eggdrop/service.sls
@@ -0,0 +1,48 @@
+# -------------------------------------------------------------
+# Salt — Deploy eggdrop park
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2017-11-19
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+{% set bots = ' '.join(pillar['viperserv_bots'].keys()) %}
+
+# -------------------------------------------------------------
+# Install service
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% if grains['os'] == 'FreeBSD' %}
+/usr/local/etc/rc.d/eggdrop:
+ file.managed:
+ - source: salt://roles/viperserv/eggdrop/files/rc/eggdrop
+ - mode: 755
+{% endif %}
+
+# -------------------------------------------------------------
+# Configure service
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% if grains['os'] == 'FreeBSD' %}
+
+/etc/rc.conf.d/eggdrop:
+ file.directory
+
+/etc/rc.conf.d/eggdrop/instances:
+ file.managed:
+ - source: salt://roles/viperserv/eggdrop/files/rc/instances
+ - template: jinja
+ - context:
+ bots: {{ bots }}
+
+{% for botname, bot in pillar['viperserv_bots'].iteritems() %}
+/etc/rc.conf.d/eggdrop/{{ botname }}:
+ file.managed:
+ - source: salt://roles/viperserv/eggdrop/files/rc/per_instance
+ - template: jinja
+ - context:
+ runas: {{ bot['runas'] | default('') }}
+ botname: {{ botname }}
+{% endfor %}
+
+{% endif %}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 03:18 (1 d, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2256144
Default Alt Text
(9 KB)

Event Timeline