forked from Maciejonos/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-system
More file actions
executable file
·158 lines (127 loc) · 4.76 KB
/
setup-system
File metadata and controls
executable file
·158 lines (127 loc) · 4.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
set -e
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
source "$SCRIPT_DIR/lib/helpers.sh"
source "$SCRIPT_DIR/lib/backup.sh"
DOTFILES_DIR="$HOME/.local/share/dotfiles"
# Configure gnome-keyring PAM
log_info "Configuring gnome-keyring PAM integration..."
[ -f "/etc/pam.d/login" ] && backup_file "/etc/pam.d/login"
[ -f "/etc/pam.d/passwd" ] && backup_file "/etc/pam.d/passwd"
# Configure /etc/pam.d/login
if ! grep -q "pam_gnome_keyring.so" /etc/pam.d/login; then
sudo sed -i '/auth.*include.*system-local-login/a auth optional pam_gnome_keyring.so' /etc/pam.d/login
sudo sed -i '/session.*include.*system-local-login/a session optional pam_gnome_keyring.so auto_start' /etc/pam.d/login
fi
# Configure /etc/pam.d/passwd
if ! grep -q "pam_gnome_keyring.so" /etc/pam.d/passwd; then
echo "password optional pam_gnome_keyring.so" | sudo tee -a /etc/pam.d/passwd >/dev/null
fi
log_success "gnome-keyring PAM configured"
# Configure pacman.conf
log_info "Configuring pacman.conf..."
PACMAN_CONF="/etc/pacman.conf"
[ -f "$PACMAN_CONF" ] && backup_file "$PACMAN_CONF"
sudo cp "$DOTFILES_DIR/default/pacman/pacman.conf" "$PACMAN_CONF"
log_success "pacman.conf configured"
# Configure UFW
if is_installed "ufw"; then
log_info "Configuring UFW..."
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 53317/udp comment 'LocalSend'
sudo ufw allow 53317/tcp comment 'LocalSend'
sudo ufw allow 22/tcp comment 'SSH'
sudo ufw --force enable
sudo systemctl enable ufw
log_success "UFW configured and enabled"
else
log_detail "UFW not installed, skipping firewall configuration"
fi
# Detect and configure NVIDIA if present
if has_nvidia_gpu; then
log_info "NVIDIA GPU detected, configuring for Hyprland..."
bash "$SCRIPT_DIR/setup-nvidia"
fi
# Configure git user
log_info "Configuring git user information..."
CURRENT_GIT_NAME=$(git config --global user.name 2>/dev/null || true)
CURRENT_GIT_EMAIL=$(git config --global user.email 2>/dev/null || true)
if [ -n "$CURRENT_GIT_NAME" ] && [ -n "$CURRENT_GIT_EMAIL" ]; then
log_detail "Git already configured:"
log_detail " Name: $CURRENT_GIT_NAME"
log_detail " Email: $CURRENT_GIT_EMAIL"
if ask_yes_no "Update git config?"; then
CURRENT_GIT_NAME=""
CURRENT_GIT_EMAIL=""
fi
fi
if [ -z "$CURRENT_GIT_NAME" ]; then
if _has_gum; then
GIT_NAME=$(gum input --placeholder "Enter your name (used for git)" || true)
else
read -p "Enter your name: " GIT_NAME
fi
if [ -n "$GIT_NAME" ]; then
git config --global user.name "$GIT_NAME"
log_success "Set git user.name: $GIT_NAME"
fi
fi
if [ -z "$CURRENT_GIT_EMAIL" ]; then
if _has_gum; then
GIT_EMAIL=$(gum input --placeholder "Enter your email (used for git)" || true)
else
read -p "Enter your email: " GIT_EMAIL
fi
if [ -n "$GIT_EMAIL" ]; then
git config --global user.email "$GIT_EMAIL"
log_success "Set git user.email: $GIT_EMAIL"
fi
fi
# ly display manager configuration
if is_installed "ly"; then
log_info "Configuring ly display manager..."
sudo mkdir -p /etc/systemd/system/ly.service.d
[ -f "/etc/systemd/system/ly.service.d/override.conf" ] && backup_file "/etc/systemd/system/ly.service.d/override.conf"
sudo cp "$DOTFILES_DIR/default/ly/override.conf" /etc/systemd/system/ly.service.d/override.conf
sudo systemctl daemon-reload
[ -f "/etc/ly/config.ini" ] && backup_file "/etc/ly/config.ini"
sudo rm -f /etc/ly/config.ini
sudo cp "$DOTFILES_DIR/default/ly/config.ini" /etc/ly/config.ini
log_success "ly display manager configured"
else
log_detail "ly not installed, skipping"
fi
# Remove wait on network from system startup
log_info "Disabling systemd-networkd-wait-online.service..."
sudo systemctl disable systemd-networkd-wait-online.service 2>/dev/null || true
# Enable ssh agent
log_info "Enabling gcr-ssh-agent"
systemctl --user enable --now gcr-ssh-agent.socket
# Setup systemd user services
log_info "Setting up systemd user services..."
mkdir -p "$HOME/.config/systemd/user"
if [ -d "$DOTFILES_DIR/default/systemd/user" ]; then
cp -f "$DOTFILES_DIR/default/systemd/user/"*.service "$HOME/.config/systemd/user/" 2>/dev/null || true
log_detail "Service files copied"
fi
systemctl --user daemon-reload 2>/dev/null || log_detail "Failed to reload systemd"
USER_SERVICES=(
"elephant.service"
"hypridle.service"
"mako.service"
"sunsetr.service"
"swayosd.service"
"walker.service"
"waybar.service"
"hyprpaper.service"
)
for service in "${USER_SERVICES[@]}"; do
if systemctl --user enable "$service" &>/dev/null; then
log_detail "$service enabled"
else
log_detail "Failed to enable $service (may be missing)"
fi
done
log_detail "Services will start on next login or Hyprland restart"
log_success "System configuration complete!"