forked from coolerguy71/FreeBSD-SetupScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
211 lines (207 loc) · 8.58 KB
/
setup.sh
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/sh
# Check if the script is being run as root
if [ "$(id -u)" -ne 0 ]; then
echo "Gotta run this as root, sorry. To execute as root, run 'su' in your terminal!"
exit 1
fi
# Function to update the repository to the latest
update_repository() {
echo "Would you like to update to the latest repository? (Probably will need this for access to many drivers and desktops) (y/n): "
read update_confirm
case "$update_confirm" in
[Yy])
echo "Updating /etc/pkg/FreeBSD.conf to the latest repository..."
echo "Alright, updating FreeBSD to the latest repo!"
echo 'FreeBSD: {' > /etc/pkg/FreeBSD.conf
echo ' url: "pkg+https://pkg.FreeBSD.org/${ABI}/latest",' >> /etc/pkg/FreeBSD.conf
echo ' mirror_type: "srv",' >> /etc/pkg/FreeBSD.conf
echo '}' >> /etc/pkg/FreeBSD.conf
echo "Repository updated to the latest."
;;
[Nn])
echo "Alright, no changes made."
;;
*)
echo "Invalid response. Please enter y or n."
exit 1
;;
esac
}
configure_graphics() {
echo "Select graphics provider. Your options are: 'Intel', 'AMD', 'AMDRX7000' (Newest Lineup, or newer drivers if you want that :),) 'Nvidia', 'Virtualbox', and 'VMWare': "
read provider_name
case "$provider_name" in
Intel)
install_command="pkg install -y drm-kmod libva-intel-driver xf86-video-intel"
kld_command="sysrc kld_list+=i915kms"
;;
AMD)
install_command="pkg install -y drm-kmod xf86-video-amdgpu"
kld_command="sysrc kld_list+=amdgpu"
;;
AMDRX7000)
install_command="pkg install -y amd-gpu-firmware-kmod xf86-video-amdgpu && cd /usr/ports/graphics/drm-61-kmod && make -DBATCH install clean"
kld_command="sysrc kld_list+=amdgpu"
;;
Nvidia)
install_command="pkg install -y nvidia-driver"
kld_command="sysrc kld_list+=nvidia-modeset"
;;
Virtualbox)
install_command="pkg install -y virtualbox-ose-additions && sysrc vboxguest_enable=\"YES\" && sysrc vboxserviceenable=\"YES\" && whoami"
kld_command="sysrc kld_list+=vboxvideo"
;;
VMWare)
install_command="pkg install -y xf86-video-vmware"
kld_command="sysrc kld_list+=vmwgfx"
;;
*)
echo "Invalid option. Please choose between Intel, AMD, or Nvidia. Virtualbox or VMware.."
exit 1
;;
esac
# Display the selected provider and ask for confirmation
echo "You selected $provider_name."
echo "Do you want to install drivers for $provider_name? (y/n): "
read confirm
case "$confirm" in
[Yy])
echo "Installing drivers for $provider_name..."
eval "$install_command"
eval "$kld_command"
echo "Drivers installed and configured."
# Prompt for the non-root username and add to the video group
echo "Enter the username of the non-root user to add to the video group: "
read username
pw groupmod video -m "$username"
echo "User $username has been added to the video group."
;;
[Nn])
echo "Installation canceled."
exit 0
;;
*)
echo "Invalid response. Please enter y or n."
exit 1
;;
esac
# Ask for desktop environment or Wayland compositor
echo "Do you want to install an X-based desktop environment, or a Wayland compositor? Type 'xorg' for an X-based DE, and 'wayland' for a compositor."
read choice
case "$choice" in
xorg)
echo "Alright, you have the following options: Plasma Plasma-Minimal Gnome Gnome-Minimal XFCE Mate Mate-Minimal Cinnamon LXQT"
echo "Choose your desktop environment: "
read de_choice
case "$de_choice" in
Plasma)
echo "You selected KDE Plasma."
confirm_install "pkg install -y kde5 sddm xorg && sysrc dbus_enable=\"YES\" && sysrc sddm_enable=\"YES\""
;;
Plasma-Minimal)
echo "You selected KDE Plasma Minimal."
confirm_install "pkg install -y plasma5-plasma konsole dolphin sddm xorg && sysrc dbus_enable=\"YES\" && sysrc sddm_enable=\"YES\""
;;
Gnome)
echo "You selected GNOME."
confirm_install "pkg install -y gnome xorg && sysrc dbus_enable=\"YES\" && sysrc gdm_enable=\"YES\""
;;
Gnome-Minimal)
echo "You selected GNOME Minimal."
confirm_install "pkg install -y gnome-lite gnome-terminal xorg && sysrc dbus_enable=\"YES\" && sysrc gdm_enable=\"YES\""
;;
XFCE)
echo "You selected XFCE."
confirm_install "pkg install -y xfce lightdm lightdm-gtk-greeter xorg && sysrc dbus_enable=\"YES\" && sysrc lightdm_enable=\"YES\""
;;
Mate)
echo "You selected MATE."
confirm_install "pkg install -y mate lightdm lightdm-gtk-greeter xorg && sysrc dbus_enable=\"YES\" && sysrc lightdm_enable=\"YES\""
;;
Mate-Minimal)
echo "You selected MATE Minimal."
confirm_install "pkg install -y mate-base mate-terminal lightdm lightdm-gtk-greeter xorg && sysrc dbus_enable=\"YES\" && sysrc lightdm_enable=\"YES\""
;;
Cinnamon)
echo "You selected Cinnamon."
confirm_install "pkg install -y cinnamon lightdm lightdm-gtk-greeter xorg && sysrc dbus_enable=\"YES\" && sysrc lightdm_enable=\"YES\""
;;
LXQT)
echo "You selected LXQT."
confirm_install "pkg install -y lxqt sddm xorg && sysrc dbus_enable=\"YES\" && sysrc sddm_enable=\"YES\""
;;
*)
echo "Invalid option. Please choose from the listed options."
exit 1
;;
esac
;;
wayland)
echo "You have the following options: Hyprland Sway SwayFX"
echo "Choose your Wayland compositor: "
read compositor_choice
case "$compositor_choice" in
Hyprland)
echo "You selected Hyprland."
confirm_install "pkg install -y hyprland kitty wayland seatd && sysrc seatd_enable=\"YES\" && sysrc dbus_enable=\"YES\" && service seatd start"
;;
Sway)
echo "You selected Sway."
confirm_install "pkg install -y sway foot wayland seatd && sysrc seatd_enable=\"YES\" && sysrc dbus_enable=\"YES\" && service seatd start"
;;
SwayFX)
echo "You selected SwayFX."
confirm_install "pkg install -y swayfx foot wayland seatd && sysrc seatd_enable=\"YES\" && sysrc dbus_enable=\"YES\" && service seatd start"
;;
*)
echo "Invalid option. Please choose from the listed options."
exit 1
;;
esac
;;
*)
echo "Invalid option. Please choose 'xorg' or 'wayland'."
exit 1
;;
esac
}
# Function to confirm and install the selected package
confirm_install() {
local command="$1"
echo "Do you want to proceed with the following command? $command (y/n): "
read confirm
case "$confirm" in
[Yy])
echo "Executing: $command"
eval "$command"
echo "Installation and configuration complete."
;;
[Nn])
echo "Installation canceled."
;;
*)
echo "Invalid response. Please enter y or n."
exit 1
;;
esac
}
# Update repository if user agrees
update_repository
# Run the function
configure_graphics
# Prompt the user to reboot the system
echo "Do you want to reboot the system now? (y/n): "
read reboot_confirm
case "$reboot_confirm" in
[Yy])
echo "Rebooting..."
reboot
;;
[Nn])
echo "You want to keep the terminal, eh? Reboot anytime by simply typing 'reboot!'"
;;
*)
echo "Invalid response. Please enter y or n."
exit 1
;;
esac