4 # Repeatedly parse config file for GPG key and bot screen configs.
6 db_dir="${HOME}/plomlombot_db"
7 irclogs_dir=/var/www/html/irclogs
9 cat "${path}" | while read line; do
10 first_word=$(echo -n "${line}" | cut -d' ' -f1)
12 # Read "bot:" line, start bot screen session from it if not yet existing,
13 # set up irclogs dir if not yet existing.
14 if [ "${first_word}" = "bot:" ]; then
15 session_name=$(echo -n "${line}" | cut -d' ' -f2)
16 bot_name=$(echo -n "${line}" | cut -d' ' -f3)
17 channel_name=$(echo -n "${line}" | cut -d' ' -f4)
18 server_name=$(echo -n "${line}" | cut -d' ' -f5)
20 screen -S "${session_name}" -Q select . > /dev/null
23 if [ "${start_screen}" -eq "1" ]; then
25 screen -d -m -S "${session_name}" ./run.sh -n "${bot_name}" -s "${server_name}" "${channel_name}"
27 md5_server=$(echo -n "${server_name}" | md5sum | cut -d' ' -f1)
28 md5_channel=$(echo -n "${channel_name" | md5sum | cut -d' ' -f1)
29 logs_dir="${db_dir}/${md5_server}/${md5_channel}/logs"
30 # FIXME: Note the trouble we will have if we have the same channel
31 # name on different servers …
32 ln -sf "${logs_dir}" "${irclogs_dir}/${channel_name}"
34 # If "key:" line, encrypt old raw logs to that GPG key.
35 elif [ "${first_word}" = "gpg_key": ]; then
36 key=$(echo -n "${line}" | cut -d' ' -f2)
38 find . -path '*/*/raw_logs/*.txt' -mtime +1 -type f -exec gpg --recipient "${key}" --trust-model always --encrypt {} \; -exec rm {} \;