-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·112 lines (98 loc) · 3.05 KB
/
install.sh
File metadata and controls
executable file
·112 lines (98 loc) · 3.05 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# Define and sort all required packages
required_packages=(
build-essential
ca-certificates
curl
fzf
gnome-control-center
jq
libbz2-dev
libffi-dev
liblzma-dev
libncursesw5-dev
libreadline-dev
libsqlite3-dev
libssl-dev
libxmlsec1-dev
libxml2-dev
ninja-build
openjdk-11-jdk
openvpn
python3-dev
tk-dev
tmux
tree
unzip
wget
xclip
xz-utils
zlib1g-dev
zsh
)
echo "Updating package list and ensuring all utilities are installed or at their latest version..."
sudo apt update
# Install or update all required packages
sudo apt install -y "${required_packages[@]}"
# Special handling for GitHub CLI (gh)
if ! command -v gh &> /dev/null; then
echo "Installing GitHub CLI (gh) from official repository..."
sudo mkdir -p -m 755 /etc/apt/keyrings
out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg
cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh -y
else
echo "GitHub CLI (gh) is already installed: $(gh --version | head -n 1)"
fi
# Install Just if not already installed
if ! type just &> /dev/null; then
echo "Installing Just..."
# Download the prebuilt binary directly
JUST_VERSION="1.19.0"
ARCH=$(uname -m)
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$ARCH" in
x86_64) ARCH="x86_64" ;;
aarch64) ARCH="aarch64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
JUST_DOWNLOAD_URL="https://github.com/casey/just/releases/download/${JUST_VERSION}/just-${JUST_VERSION}-${ARCH}-unknown-${OS}-musl.tar.gz"
wget -q "$JUST_DOWNLOAD_URL" -O just.tar.gz
tar -xzf just.tar.gz just
sudo mv just /usr/local/bin/
rm just.tar.gz
echo "Just installed successfully."
fi
# Check if user.name and user.email are already set
user_name=$(git config --get user.name)
user_email=$(git config --get user.email)
if [ -z "$user_name" ]; then
read -r -p "Enter your GitHub full name: " user_name
git config --global user.name "$user_name"
fi
if [ -z "$user_email" ]; then
read -r -p "Enter your email address: " user_email
git config --global user.email "$user_email"
fi
# Check if the default shell is Zsh
if [ "$SHELL" = "$(which zsh)" ]; then
echo "Default shell is already Zsh."
else
echo "Default shell is not Zsh. Attempting to change shell to Zsh..."
if sudo chsh -s "$(which zsh)" "$USER"; then
touch ${HOME}/.zshrc
echo "Shell changed to Zsh. Please re-login and rerun this script."
echo "Or run"
echo "cd ${HOME}/dotfiles && just"
echo "Exiting..."
sleep 3
exit 0
else
echo "Failed to change the shell. Please have someone with root access run 'chsh -s $(which zsh) $USER'."
fi
fi
# Run just to execute the default recipe
just