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