-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_in_docker.sh
More file actions
executable file
·58 lines (51 loc) · 1.76 KB
/
Copy pathinstall_in_docker.sh
File metadata and controls
executable file
·58 lines (51 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Installs scripts, dotfiles, and other conveniences automatically. This script
# must be run from this directory or behavior is undefined.
#
# This script is intended to be run inside a Docker container to set up a simple
# environment, and must run non-interactively.
set -x
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes
# Prints an error (all arguments) to stderr.
error () {
echo -e "\e[32m$@\e[0m" >&2
}
SCRIPT_PATH="$(dirname "$(realpath "$0")")"
if [[ $SCRIPT_PATH != $(pwd) ]] ; then
error "Run install.sh from the directory where it is located ($SCRIPT_PATH)."
exit 1
fi
apt-get update
# Install any tools so we can use them below if needed.
for tool in $(cat tools); do
echo "Installing $tool..."
apt-get install -y --no-install-recommends "$tool"
done
# Safely installs a dotfile.
# $1 - Where to register the dotfile (e.g. "~/.bashrc").
# $2 - The location of the dotfile to use (e.g.
# "$SCRIPT_PATH/dotfiles/bashrc").
set_dotfile () {
if [[ -L $1 ]] ; then
if [[ $2 == $(realpath "$1") ]] ; then
echo "$1 already installed correctly."
return 0
fi
echo "Removing previous symbolic link at $1 (which pointed to $2)..."
rm --force $1
fi
echo "Installing $1..."
ln --symbolic --backup=numbered "$2" "$1"
}
for file in $(ls dotfiles); do
set_dotfile ~/."$file" "$SCRIPT_PATH/dotfiles/$file"
done
set_dotfile ~/.scripts "$SCRIPT_PATH/scripts"
mkdir -p ~/.config/jj
set_dotfile ~/.config/jj/config.toml "$SCRIPT_PATH/configs/jj.toml"
# Install JJ
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
$HOME/.cargo/bin/cargo install --locked --bin jj jj-cli
source <($HOME/.cargo/bin/jj util completion bash)