-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01.init
executable file
·85 lines (78 loc) · 2.71 KB
/
01.init
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
#!/usr/bin/env bash
set -Ceuo pipefail
trap exit ERR
echo "=== Checking Package Installation ==="
if ! type vim zsh git tmux cmake >/dev/null 2>&1; then
echo "Installing required packages..."
if type apt-get >/dev/null 2>&1; then
echo "Detected Debian/Ubuntu system"
sudo apt-get update
sudo apt-get -y install vim zsh git tmux cmake build-essential avahi-daemon
sudo systemctl start avahi-daemon
sudo systemctl enable avahi-daemon
elif type dnf >/dev/null 2>&1; then
echo "Detected Fedora system"
sudo dnf -y groupinstall "Development Tools"
sudo dnf -y install vim zsh git tmux cmake kernel-devel kernel-headers avahi
sudo systemctl start avahi-daemon
sudo systemctl enable avahi-daemon
elif type yum >/dev/null 2>&1; then
echo "Detected RHEL/CentOS system"
sudo yum -y groupinstall "Development Tools"
sudo yum -y install vim zsh git tmux cmake kernel-devel kernel-headers avahi
sudo systemctl start avahi-daemon
sudo systemctl enable avahi-daemon
elif type pacman >/dev/null 2>&1; then
echo "Detected Arch system"
sudo pacman -S --needed vim zsh git tmux cmake base-devel avahi
else
echo "Error: No supported package manager found"
echo "Please install the following packages manually:"
echo " - vim, zsh, git, tmux, cmake, build-essential"
return 2>&- || exit
fi
echo "Package installation completed"
else
echo "Required packages are already installed - Skipping installation"
fi
echo -e "\n=== Checking GitHub SSH Configuration ==="
if [ ! -d ~/.ssh ]; then
echo "Creating ~/.ssh directory"
mkdir -p ~/.ssh
chmod 700 ~/.ssh
else
echo "SSH directory already exists - Skipping creation"
fi
if ! grep -q "host github" ~/.ssh/config 2>/dev/null && ! ssh -o StrictHostKeyChecking=no -T [email protected] 2>/dev/null; then
echo "Setting up GitHub SSH access..."
if [ ! -f ~/.ssh/github ]; then
echo "Generating new SSH key"
ssh-keygen -t ed25519 -b 521 -C '' -N '' -f ~/.ssh/github
else
echo "SSH key already exists - Skipping generation"
fi
if ! grep -q "host github" ~/.ssh/config 2>/dev/null; then
echo "Adding SSH configuration"
cat << EOF > ~/.ssh/config
host github github.com
Hostname github.com
IdentityFile ~/.ssh/github
User git
EOF
chmod 600 ~/.ssh/config
else
echo "SSH config already exists - Skipping configuration"
fi
echo -e "\nGitHub public key:"
echo "----------------------------------------"
cat ~/.ssh/github.pub
echo "----------------------------------------"
echo -e "\n1. Visit: https://github.com/settings/ssh/new"
echo "2. Register the above public key to GitHub"
read -p "3. Press Enter when registration is complete"
echo "Testing GitHub connection..."
ssh -T [email protected]
else
echo "GitHub SSH access is already configured - Skipping setup"
exit 0
fi