home · contact · privacy
Add isync setup.
[config] / buster / setup_scripts / setup_home_eeepc.sh
1 #!/bin/sh
2 set -e
3
4 public_repos_dir="${HOME}/public_repos"
5 config_tree_prefix="${public_repos_dir}/config"
6 path_borgscript="${config_tree_prefix}/all_new_2018/borg.sh"
7 config_tree_buster="${config_tree_prefix}/buster"
8 setup_scripts_dir="${config_tree_buster}/setup_scripts"
9 repos_list_file="${public_repos_dir}/repos"
10 dir_secrets="${HOME}/tmp_secrets"
11 borgkeys_dir=~/.config/borg/keys
12 borgrepos_file=~/.borgrepos
13 ssh_dir=~/.ssh
14 imap_pass_file=.imap_pass
15
16 ensure_repo() {
17     repo_name="${1}"
18     if [ ! -d "${public_repos_dir}/${repo_name}" ]; then
19         cd "${public_repos_dir}"
20         git clone https://plomlompom.com/repos/clone/${repo_name}
21     fi
22 }
23
24 # Clone config to copy dotfiles etc. from it.
25 cd
26 mkdir -p "${public_repos_dir}"
27 ensure_repo config
28 cd "${setup_scripts_dir}"
29 ./copy_dirtree.sh "${config_tree_buster}/home_files" "${HOME}" minimal user_eeepc
30
31 # Set up native messenger for tridactyl.
32 curl -fsSl https://raw.githubusercontent.com/tridactyl/tridactyl/78e662efefd1f4af2bdb2a53edecf03b535b997b/native/install.sh | bash
33
34 # Set up non-public parts of infrastructure.
35 cd "${dir_secrets}"
36 mkdir -p "${ssh_dir}"
37 echo "Setting up .ssh"
38 cp id_rsa ~/.ssh
39 stty -echo
40 ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
41 stty echo
42 tar xf borg_keyfiles.tar
43 mkdir -p "${borgkeys_dir}"
44 mv borg_keyfiles/* "${borgkeys_dir}"
45 if [ -f "${imap_pass_file}" ]; then
46     cp "${imap_pass_file}" ~
47 fi
48 cd
49 rm -rf "${dir_secrets}"
50
51 # Sync org dir via borgbackup. For this we need the borgbackup servers
52 # in our .ssh/known_hosts file.
53 cat "${borgrepos_file}" | while read line; do
54     first_char=$(echo "${line}" | cut -c1)
55     if [ "${first_char}" = "#" ]; then
56         continue
57     fi
58     server=$(echo "${line}" | sed 's/.*@//')
59     ssh-keyscan "${server}" >> "${ssh_dir}"/known_hosts
60 done
61 BORG_PASSPHRASE="${SECRETS_PASS}" "${path_borgscript}" orgpull
62
63 # Fill ~/public_repos.
64 cat "${repos_list_file}" | while read line; do
65     first_char=$(echo "${line}" | cut -c1)
66     if [ "${first_char}" = "#" ]; then
67         continue
68     fi
69     ensure_repo "${line}"
70 done
71
72 # Set up e-mail system. Note that we only do mbsync if the imap pass file
73 # is found. It may not be present on every secrets drive yet, so we have to
74 # deal with the possibility of it being absent at this point.
75 mkdir -p ~/Mail/maildir  # expected by mbsync/isync
76 if [ -f "~/${imap_pass_file}" ]; then
77     mbsync -a
78 fi
79
80 # Final note on how to integrate tridactyl.
81 echo "TODO: As tridactyl user, don't forget to do :source on the first Firefox run and then re-start."