home · contact · privacy
Improve/fix secrets installation.
[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 ssh_dir=~/.ssh
13
14 ensure_repo() {
15     repo_name="${1}"
16     if [ ! -d "${public_repos_dir}/${repo_name}" ]; then
17         cd "${public_repos_dir}"
18         git clone https://plomlompom.com/repos/clone/${repo_name}
19     fi
20 }
21
22 # Clone config to copy dotfiles etc. from it.
23 cd
24 mkdir -p "${public_repos_dir}"
25 ensure_repo config
26 cd "${setup_scripts_dir}"
27 ./copy_dirtree.sh "${config_tree_buster}/home_files" "${HOME}" minimal user_eeepc
28
29 # Set up native messenger for tridactyl.
30 curl -fsSl https://raw.githubusercontent.com/tridactyl/tridactyl/78e662efefd1f4af2bdb2a53edecf03b535b997b/native/install.sh | bash
31
32 # Set up non-public parts of infrastructure.
33 cd "${dir_secrets}"
34 mkdir -p "${ssh_dir}"
35 echo "Setting up .ssh"
36 cp id_rsa ~/.ssh
37 stty -echo
38 ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
39 stty echo
40 tar xf borg_keyfiles.tar
41 mkdir -p "${borgkeys_dir}"
42 mv borg_keyfiles/* "${borgkeys_dir}"
43 cd
44 rm -rf "${dir_secrets}"
45
46 # Sync org dir via borgbackup. For this we need the borgbackup servers
47 # in our .ssh/known_hosts file.
48 cat "${borgconfig_file}" | while read line; do
49     first_char=$(echo "${line}" | cut -c1)
50     if [ "${first_char}" = "#" ]; then
51         continue
52     fi
53     ssh-keyscan "${line}" >> "${ssh_dir}"/known_hosts
54 done
55 "${path_borgscript}" orgpull
56
57 # Fill ~/public_repos.
58 cat "${repos_list_file}" | while read line; do
59     first_char=$(echo "${line}" | cut -c1)
60     if [ "${first_char}" = "#" ]; then
61         continue
62     fi
63     ensure_repo "${line}"
64 done
65
66 # Final note on how to integrate tridactyl.
67 echo "TODO: As tridactyl user, don't forget to do :source on the first Firefox run and then re-start."