Page MenuHomeDevCentral

D1236.id3176.diff
No OneTemporary

D1236.id3176.diff

diff --git a/roles/viperserv/account/init.sls b/roles/viperserv/account/init.sls
--- a/roles/viperserv/account/init.sls
+++ b/roles/viperserv/account/init.sls
@@ -27,7 +27,7 @@
file.directory:
- user: {{ user['uid'] }}
- group: nasqueron-irc
- - dir_mode: 700
+ - dir_mode: 711
{% endfor %}
diff --git a/roles/viperserv/eggdrop/files/rc/eggdrop b/roles/viperserv/eggdrop/files/rc/eggdrop
new file mode 100755
--- /dev/null
+++ b/roles/viperserv/eggdrop/files/rc/eggdrop
@@ -0,0 +1,99 @@
+#!/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}
+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
--- /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
--- /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
--- a/roles/viperserv/eggdrop/init.sls
+++ b/roles/viperserv/eggdrop/init.sls
@@ -9,3 +9,4 @@
include:
- .software
- .config
+ - .service
diff --git a/roles/viperserv/eggdrop/service.sls b/roles/viperserv/eggdrop/service.sls
new file mode 100644
--- /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/plain
Expires
Sun, Nov 24, 06:40 (8 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2259619
Default Alt Text
D1236.id3176.diff (7 KB)

Event Timeline