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