--- /dev/null
+[Unit]
+Description=Pull website repo
+[Service]
+Type=oneshot
+User=plom
+ExecStart=/bin/sh -c '~/encrypter.sh'
--- /dev/null
+[Unit]
+Description=Attempt encryption of old chatlogs once every minute.
+
+[Timer]
+OnCalendar=*-*-* *:*:00
+
+[Install]
+WantedBy=timers.target
\ No newline at end of file
text/html html htm shtml;
text/css css;
text/xml xml;
- text/plain txt sh rst md;
+ text/plain txt sh rst md asc;
application/xhtml+xml xhtml;
application/pdf pdf;
image/jpeg jpg jpeg;
--- /dev/null
+#!/bin/sh
+set -e
+
+# Ensure we have a GPG target to encrypt to.
+if [ $# -lt 1 ]; then
+ echo "Need public key ID as argument."
+ false
+fi
+gpg_key="$1"
+
+config_tree_prefix="${HOME}/config/all_new_2018/"
+apt -y install weechat screen vim
+cp "${config_tree_prefix}user_files/encrypter.sh /home/plom/"
+chown plom:plom /home/plom/encrypter.sh
+cp "${config_tree_prefix}user_files/weechat-wrapper.sh /home/plom/"
+chown plom:plom /home/plom/weechat-wrapper.sh
+cp "${config_tree_prefix}user_files/weechatrc /home/plom/.weechatrc"
+chown plom:plom /home/plom/.weechatrc
+apt -y install screen gnupg dirmngr
+keyservers='sks-keyservers.net/ keys.gnupg.net'
+set +e
+while true; do
+ do_break=0
+ for keyserver in $(echo "${keyservers}"); do
+ su plom -c "gpg --no-tty --keyserver $keyserver --recv-key ${gpg_key}"
+ if [ $? -eq "0" ]; then
+ do_break=1
+ break
+ fi
+ echo "Attempt with keyserver ${keyserver} unsuccessful, trying other."
+ done
+ if [ "${do_break}" -eq "1" ]; then
+ break
+ fi
+done
+set -e
+echo "$gpg_key" > /home/plom/.encrypt_target
+chown plom:plom /home/plom/.encrypt_target
+# TODO: We may remove dirmngr here if only this script installed it.
+service encrypt_chatlogs.timer start
config_tree_prefix="${HOME}/config/all_new_2018/"
irclogs_dir=/var/www/html/irclogs
irclogs_pw_dir=/var/www/irclogs_pw
-cp "${config_tree_prefix}"/user_scripts/plomlombot_daemon.sh /home/plom/
+cp "${config_tree_prefix}"/user_files/plomlombot_daemon.sh /home/plom/
chown plom:plom /home/plom/plomlombot_daemon.sh
apt -y install screen python3-venv gnupg dirmngr
keyservers='sks-keyservers.net/ keys.gnupg.net'
--- /dev/null
+#!/bin/sh
+set -e
+
+gpg_key=$(cat ~/.encrypt_target)
--- /dev/null
+#!/bin/sh
+set -e
+
+# Repeatedly parse config file for GPG key and bot screen configs.
+path=~/.plomlombot
+db_dir="${HOME}/plomlombot_db"
+irclogs_dir=/var/www/html/irclogs
+irclogs_pw_dir=/var/www/irclogs_pw
+while true; do
+ if [ -f "${path}" ]; then
+ cat "${path}" | while read line; do
+ first_word=$(echo -n "${line}" | cut -d' ' -f1)
+
+ # Read "bot:" line, start bot screen session from it if not yet existing,
+ # set up irclogs dir if not yet existing.
+ if [ "${first_word}" = "bot:" ]; then
+ session_name=$(echo -n "${line}" | cut -d' ' -f2)
+ bot_name=$(echo -n "${line}" | cut -d' ' -f3)
+ channel_name=$(echo -n "${line}" | cut -d' ' -f4)
+ shortened_channel_name="${channel_name}"
+ first_char=$(echo -n "${channel_name}" | cut -c1)
+ if [ "${first_char}" = "#" ]; then
+ shortened_channel_name=$(echo -n "${channel_name}" | cut -c2-)
+ fi
+ server_name=$(echo -n "${line}" | cut -d' ' -f5)
+ login_user=$(echo -n "${line}" | cut -d' ' -f6)
+ login_pw=$(echo -n "${line}" | cut -d' ' -f7)
+ set +e
+ screen -S "${session_name}" -Q select . > /dev/null
+ start_screen=$?
+ set -e
+ if [ "${start_screen}" -eq "1" ]; then
+ cd ~/plomlombot-irc
+ LANG="en_US.UTF-8" screen -d -m -S "${session_name}" ./run.sh -r 604800 -n "${bot_name}" -s "${server_name}" "${channel_name}"
+ fi
+ md5_server=$(echo -n "${server_name}" | md5sum | cut -d' ' -f1)
+ md5_channel=$(echo -n "${channel_name}" | md5sum | cut -d' ' -f1)
+ logs_dir="${db_dir}/${md5_server}/${md5_channel}/logs"
+ # FIXME: Note the trouble we will have if we have the same channel
+ # name on different servers …
+ ln -sfn "${logs_dir}" "${irclogs_dir}/${shortened_channel_name}"
+ echo "${login_user}":'{PLAIN}'"${login_pw}" > "${irclogs_pw_dir}/${shortened_channel_name}"
+
+ # If "key:" line, encrypt old raw logs to that GPG key.
+ elif [ "${first_word}" = "gpg_key": ]; then
+ key=$(echo -n "${line}" | cut -d' ' -f2)
+ mkdir -p ~/plomlombot_db
+ cd ~/plomlombot_db
+ find . -path '*/*/raw_logs/*.txt' -mtime +1 -type f -exec gpg --recipient "${key}" --trust-model always --encrypt {} \; -exec rm {} \;
+ fi
+
+ done
+ sleep 1
+ fi
+done
--- /dev/null
+#!/bin/sh
+
+# Enforce ~/.weechatrc as sole persistent weechat config file.
+#~/config/bin/simplemail.sh ~/config/mails/weechat_restart_reminder
+rm -rf ~/.weechat/
+WEECHATCONF=`tr '\n' ';' < ~/.weechatrc`
+weechat -r "$WEECHATCONF"
+rm -rf ~/.weechat/
--- /dev/null
+/set logger.file.path ~/weechatlogs
+/set logger.file.flush_delay 0
+/set logger.mask.irc "irc/$server/$channel.%Y-%m-%d.weechatlog"
+/set weechat.bar.status.items "[time],[buffer_last_number],[buffer_plugin],buffer_number+:+buffer_name+(buffer_modes)+{buffer_nicklist_count}+buffer_zoom+buffer_filter,[lag],[hotlist],completion,scroll,[otr]"
+/set weechat.color.chat_nick_colors "lightcyan"
+/server add freenode irc.freenode.net -nicks=plimlompom,plimlomp0m,pliml0mp0m -realname="foo bar" -autojoin=#plomlompomtest
+/connect freenode
+++ /dev/null
-#!/bin/sh
-set -e
-
-# Repeatedly parse config file for GPG key and bot screen configs.
-path=~/.plomlombot
-db_dir="${HOME}/plomlombot_db"
-irclogs_dir=/var/www/html/irclogs
-irclogs_pw_dir=/var/www/irclogs_pw
-while true; do
- if [ -f "${path}" ]; then
- cat "${path}" | while read line; do
- first_word=$(echo -n "${line}" | cut -d' ' -f1)
-
- # Read "bot:" line, start bot screen session from it if not yet existing,
- # set up irclogs dir if not yet existing.
- if [ "${first_word}" = "bot:" ]; then
- session_name=$(echo -n "${line}" | cut -d' ' -f2)
- bot_name=$(echo -n "${line}" | cut -d' ' -f3)
- channel_name=$(echo -n "${line}" | cut -d' ' -f4)
- shortened_channel_name="${channel_name}"
- first_char=$(echo -n "${channel_name}" | cut -c1)
- if [ "${first_char}" = "#" ]; then
- shortened_channel_name=$(echo -n "${channel_name}" | cut -c2-)
- fi
- server_name=$(echo -n "${line}" | cut -d' ' -f5)
- login_user=$(echo -n "${line}" | cut -d' ' -f6)
- login_pw=$(echo -n "${line}" | cut -d' ' -f7)
- set +e
- screen -S "${session_name}" -Q select . > /dev/null
- start_screen=$?
- set -e
- if [ "${start_screen}" -eq "1" ]; then
- cd ~/plomlombot-irc
- LANG="en_US.UTF-8" screen -d -m -S "${session_name}" ./run.sh -r 604800 -n "${bot_name}" -s "${server_name}" "${channel_name}"
- fi
- md5_server=$(echo -n "${server_name}" | md5sum | cut -d' ' -f1)
- md5_channel=$(echo -n "${channel_name}" | md5sum | cut -d' ' -f1)
- logs_dir="${db_dir}/${md5_server}/${md5_channel}/logs"
- # FIXME: Note the trouble we will have if we have the same channel
- # name on different servers …
- ln -sfn "${logs_dir}" "${irclogs_dir}/${shortened_channel_name}"
- echo "${login_user}":'{PLAIN}'"${login_pw}" > "${irclogs_pw_dir}/${shortened_channel_name}"
-
- # If "key:" line, encrypt old raw logs to that GPG key.
- elif [ "${first_word}" = "gpg_key": ]; then
- key=$(echo -n "${line}" | cut -d' ' -f2)
- mkdir -p ~/plomlombot_db
- cd ~/plomlombot_db
- find . -path '*/*/raw_logs/*.txt' -mtime +1 -type f -exec gpg --recipient "${key}" --trust-model always --encrypt {} \; -exec rm {} \;
- fi
-
- done
- sleep 1
- fi
-done