apiVersion: v1
kind: ConfigMap
metadata:
  name: anope
  labels:
    app: anope
data:
  RS_CONFIG_FILE: "/pod/config.yml"
  DB_HOST: "mariadb"
  DB_NAME: "anope"
  DB_USERNAME: "anope"
  UPLINK_PASSWORD: "banana"
  services.conf.template: |
    define
    {
    	name = "services.host"
    	value = "services.##FAF_BASE_DOMAIN##"
    }

    uplink
    {
    	host = "unrealircd"
    	port = 7000
    	ipv6 = no
    	ssl = no
    	password = "${UPLINK_PASSWORD}"
    }

    serverinfo
    {
    	name = "services.##FAF_BASE_DOMAIN##"
    	description = "Services for IRC Networks"
    	pid = "data/services.pid"
    	motd = "conf/services.motd"
    }

    module
    {
    	name = "unreal4"
    	use_server_side_mlock = yes
    	use_server_side_topiclock = yes
    }

    networkinfo
    {
    	networkname = "LocalNet"
    	nicklen = 31
    	userlen = 10
    	hostlen = 64
    	chanlen = 32
    	modelistsize = 100
    	vhost_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-"
    	allow_undotted_vhosts = false
    	disallow_start_or_end = ".-"
    }

    options
    {
    	casemap = "ascii"
    	seed = 1111111
    	strictpasswords = yes
    	badpasslimit = 5
    	badpasstimeout = 1h
    	updatetimeout = 5m
    	expiretimeout = 30m
    	readtimeout = 5s
    	warningtimeout = 4h
    	timeoutcheck = 3s
    	retrywait = 60s
    	hideprivilegedcommands = yes
    	hideregisteredcommands = yes
    	regexengine = "regex/pcre"
    	languages = "ca_ES.UTF-8 de_DE.UTF-8 el_GR.UTF-8 es_ES.UTF-8 fr_FR.UTF-8 hu_HU.UTF-8 it_IT.UTF-8 nl_NL.UTF-8 pl_PL.UTF-8 pt_PT.UTF-8 ru_RU.UTF-8 tr_TR.UTF-8"
    }

    include
    {
    	type = "file"
    	name = "botserv.example.conf"
    }

    include
    {
    	type = "file"
    	name = "chanserv.example.conf"
    }

    include
    {
    	type = "file"
    	name = "global.example.conf"
    }

    include
    {
    	type = "file"
    	name = "hostserv.example.conf"
    }

    include
    {
    	type = "file"
    	name = "memoserv.example.conf"
    }

    include
    {
    	type = "file"
    	name = "nickserv.example.conf"
    }

    include
    {
    	type = "file"
    	name = "operserv.example.conf"
    }

    log
    {
    	target = "services.log"
    	bot = "Global"
    	logage = 7

    	admin = "*"
    	override = "chanserv/* nickserv/* memoserv/set ~botserv/set botserv/*"
    	commands = "~operserv/* *"
    	servers = "*"
    	users = "connect disconnect nick"
    	other = "*"
    	rawio = no
    	debug = no
    }

    log
    {
    	target = "globops"
    	admin = "global/* operserv/chankill operserv/mode operserv/kick operserv/akill operserv/s*line operserv/noop operserv/jupe operserv/oline operserv/set operserv/svsnick operserv/svsjoin operserv/svspart nickserv/getpass */drop"
    	servers = "squit"
    	users = "oper"
    	other = "expire/* bados akill/*"
    }

    opertype
    {
    	name = "Helper"
    	commands = "hostserv/*"
    }

    opertype
    {
    	name = "Services Operator"
    	inherits = "Helper, Another Helper"
    	commands = "chanserv/list chanserv/suspend chanserv/topic memoserv/staff nickserv/list nickserv/suspend operserv/mode operserv/chankill operserv/akill operserv/session operserv/modinfo operserv/sqline operserv/oper operserv/kick operserv/ignore operserv/snline"
    	privs = "chanserv/auspex chanserv/no-register-limit memoserv/* nickserv/auspex nickserv/confirm"
    }

    opertype
    {
    	name = "Services Administrator"
    	inherits = "Services Operator"
    	commands = "botserv/* chanserv/access/list chanserv/drop chanserv/getkey chanserv/saset/noexpire memoserv/sendall nickserv/saset/* nickserv/getemail operserv/news operserv/jupe operserv/svs operserv/stats operserv/oline operserv/noop operserv/forbid global/*"
    	privs = "*"
    }

    opertype
    {
    	name = "Services Root"
    	commands = "*"
    	privs = "*"
    }

    mail
    {
    	usemail = yes
    	sendmailpath = "/usr/sbin/sendmail -t"
    	sendfrom = "services@localhost.net"
    	delay = 5m
    	registration_subject = "Nickname registration for %n"
    	registration_message = "Hi,

    				You have requested to register the nickname %n on %N.
    				Please type \" /msg NickServ CONFIRM %c \" to complete registration.

    				If you don't know why this mail was sent to you, please ignore it silently.

    				%N administrators."

    	reset_subject = "Reset password request for %n"
    	reset_message = "Hi,

    			You have requested to have the password for %n reset.
    			To reset your password, type \" /msg NickServ CONFIRM %n %c \"

    			If you don't know why this mail was sent to you, please ignore it silently.

    			%N administrators."

    	emailchange_subject = "Email confirmation"
    	emailchange_message = "Hi,

    			You have requested to change your email address from %e to %E.
    			Please type \" /msg NickServ CONFIRM %c \" to confirm this change.

    			If you don't know why this mail was sent to you, please ignore it silently.

    			%N administrators."

    	memo_subject = "New memo"
    	memo_message = "Hi %n,

    			You've just received a new memo from %s. This is memo number %d.

    			Memo text:

    			%t"
    }


    module
    {
    	name = "db_sql_live"
    	engine = "mysql/main"
    	prefix = "anope_db_"
    	import = false
    }

    module { name = "enc_md5" }

    include
    {
    	type = "file"
    	name = "modules.example.conf"
    }

    include
    {
    	type = "file"
    	name = "chanstats.example.conf"
    }

    module {
    	name = "m_mysql"
    	mysql
    	{
    		/* The name of this service. */
    		name = "mysql/main"
    		database = "${DB_NAME}"
    		server = "${DB_HOST}"
    		username = "${DB_USERNAME}"
    		password = "${DB_PASSWORD}"
    		port = 3306
    	}
    }

  # Configuration shell script
  build-config.sh: |
    #!/bin/sh
    cat /config/services.conf.template | envsubst > /pod/services.conf
