home · contact · privacy
Add PlomTube mirror setup.
[config] / bullseye / setup_scripts / setup_play.sh
1 #!/bin/sh
2 set -e
3
4 if [ "$#" -lt 1 ]; then
5   echo "Need public key ID and optionally old server IP."
6   false
7 fi
8 gpg_key="$1"
9 old_server="$2"
10
11 config_tree_prefix="${HOME}/config/bullseye"
12 ./install_for_target.sh play
13 ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" play
14 cp "${config_tree_prefix}/other_files/weechatrc" /home/plom/.weechatrc
15 cp "${config_tree_prefix}/other_files/weechat-wrapper.sh" /home/plom/
16 cp "${config_tree_prefix}/other_files/weechatlogs_encrypter.sh" /home/plom/
17 chown plom:plom /home/plom/*weechat*
18 chown plom:plom /home/plom/.weechatrc
19 echo "${gpg_key}" > /home/plom/.encrypt_target
20 chown plom:plom /home/plom/.encrypt_target
21
22 # TODO refactor with setup_website.sh
23 # Add encryption key.
24 keyservers='keyserver.ubuntu.com pgp.surf.nl pgp.rediris.es'
25 set +e
26 while true; do
27     do_break=0
28     for keyserver in $(echo "${keyservers}"); do
29         su plom -c "gpg --no-tty --keyserver $keyserver --recv-key ${gpg_key}"
30         if [ $? -eq "0" ]; then
31             do_break=1
32             break
33         fi
34         echo "Attempt with keyserver ${keyserver} unsuccessful, trying other."
35     done
36     if [ "${do_break}" -eq "1" ]; then
37         break
38     fi
39 done
40 set -e
41
42 if [ "${old_server}" != "" ]; then
43   cp "${config_tree_prefix}/setup_scripts/prepare_to_meet_server.sh" /home/plom/
44   su -lc "./prepare_to_meet_server.sh ${old_server}" plom
45   read -p'Hit Enter when you are done.' ignore
46   rm /home/plom/prepare_to_meet_server.sh
47   su -lc "scp plom@${old_server}:.ssh/authorized_keys .ssh/authorized_keys" plom
48   su -lc "scp plom@${old_server}:.weechatrc ~" plom
49   cp "${config_tree_prefix}/setup_scripts/mirror_dir.sh" /home/plom/
50   su -lc "./mirror_dir.sh ${old_server} /home/plom/weechatlogs" plom
51   rm /home/plom/mirror_dir.sh
52 fi
53
54 systemctl enable --now encrypt_chatlogs.timer