home · contact · privacy
Move secrets setup into home setup script.
[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/buster"
6 setup_scripts_dir="${config_tree_prefix}/setup_scripts"
7 repos_list_file="${public_repos_dir}/repos"
8 secrets_dev="sdb"
9 source_dir="/media/${secrets_dev}/to_usb"
10 target_dir="${HOME}/tmp_to_usb"
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 cd
23 mkdir -p "${public_repos_dir}"
24 ensure_repo config
25 cd "${setup_scripts_dir}"
26 ./copy_dirtree.sh "${config_tree_prefix}/home_files" "${HOME}" minimal user_eeepc
27 cat "${repos_list_file}" | while read line; do
28     ensure_repo "${line}"
29 done
30 curl -fsSl https://raw.githubusercontent.com/tridactyl/tridactyl/78e662efefd1f4af2bdb2a53edecf03b535b997b/native/install.sh | bash
31 while [ ! -e /dev/"${secrets_dev}" ]; do
32     echo "Put secrets drive into slot for /dev/${secrets_dev}, then hit Return."
33     read ignore
34 done
35 sudo pmount /dev/"${secrets_dev}"
36 cp -a "${source_dir}" "${target_dir}"
37 sudo pumount "${secrets_dev}"
38 echo "You can remove /dev/${secrets_dev} now."
39 cd "${target_dir}"
40 mkdir -p "${ssh_dir}"
41 echo "Setting up .ssh"
42 cp id_rsa ~/.ssh
43 ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
44 tar xf borg_keyfiles.tar
45 mkdir -p "${borgkeys_dir}"
46 mv borg_keyfiles/* "${borgkeys_dir}"
47 cd
48 rm -rf "${target_dir}"
49 echo "TODO: As tridactyl user, don't forget to do :source on the first Firefox run and then re-start."