@@ -4,12 +4,12 @@ set -euo pipefail
44BASEDIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
55
66if ! source /etc/os-release 2> /dev/null; then
7- echo " Error: Unable to detect OS (missing /etc/os-release)."
8- exit 1
7+ echo " Error: Unable to detect OS (missing /etc/os-release)."
8+ exit 1
99fi
1010
1111usage () {
12- cat << 'EOF '
12+ cat << 'EOF '
1313install-system - install Charitarth Chugh's dev environment
1414
1515Default installs non-GUI applications.
2525
2626GUI=false
2727while getopts " :hg" opt; do
28- case " $opt " in
29- h)
30- usage
31- exit 0
32- ;;
33- g) GUI=true ;;
34- ? )
35- echo " Error: Invalid option -$OPTARG "
36- echo
37- usage
38- exit 1
39- ;;
40- esac
28+ case " $opt " in
29+ h)
30+ usage
31+ exit 0
32+ ;;
33+ g) GUI=true ;;
34+ ? )
35+ echo " Error: Invalid option -$OPTARG "
36+ echo
37+ usage
38+ exit 1
39+ ;;
40+ esac
4141done
4242
4343run_cli () {
44- # Determine package manager family using ID, with fallback to ID_LIKE
45- local family
46- family=" $( detect_family) "
47- case " $family " in
48- apt) " $BASEDIR /scripts/apt-cli.sh" ;;
49- yay) " $BASEDIR /scripts/yay-cli.sh" ;;
50- dnf) " $BASEDIR /scripts/dnf-cli.sh" ;;
51- * )
52- echo " Error: Unsupported distribution: ID='${ID:- unknown} ', ID_LIKE='${ID_LIKE:- } '"
53- exit 1
54- ;;
55- esac
44+ # Determine package manager family using ID, with fallback to ID_LIKE
45+ local family
46+ family=" $( detect_family) "
47+ case " $family " in
48+ apt) " $BASEDIR /scripts/apt-cli.sh" ;;
49+ yay) " $BASEDIR /scripts/yay-cli.sh" ;;
50+ dnf) " $BASEDIR /scripts/dnf-cli.sh" ;;
51+ * )
52+ echo " Error: Unsupported distribution: ID='${ID:- unknown} ', ID_LIKE='${ID_LIKE:- } '"
53+ exit 1
54+ ;;
55+ esac
5656}
5757
5858run_gui () {
59- # Determine package manager family using ID, with fallback to ID_LIKE
60- local family
61- family=" $( detect_family) "
62- case " $family " in
63- apt) " $BASEDIR /scripts/apt-gui.sh" ;;
64- yay) " $BASEDIR /scripts/yay-gui.sh" ;;
65- dnf) " $BASEDIR /scripts/dnf-gui.sh" ;;
66- * )
67- echo " Error: Unsupported distribution: ID='${ID:- unknown} ', ID_LIKE='${ID_LIKE:- } '"
68- exit 1
69- ;;
70- esac
59+ # Determine package manager family using ID, with fallback to ID_LIKE
60+ local family
61+ family=" $( detect_family) "
62+ case " $family " in
63+ apt) " $BASEDIR /scripts/apt-gui.sh" ;;
64+ yay) " $BASEDIR /scripts/yay-gui.sh" ;;
65+ dnf) " $BASEDIR /scripts/dnf-gui.sh" ;;
66+ * )
67+ echo " Error: Unsupported distribution: ID='${ID:- unknown} ', ID_LIKE='${ID_LIKE:- } '"
68+ exit 1
69+ ;;
70+ esac
7171}
7272
7373detect_family () {
74- # Maps distro IDs to a package manager "family": apt | yay | dnf
75- case " ${ID:- } " in
76- ubuntu | debian)
77- echo apt
78- return 0
79- ;;
80- arch | artix)
81- echo yay
82- return 0
83- ;;
84- fedora | rhel | centos)
85- echo dnf
86- return 0
87- ;;
88- esac
89-
90- # Fallback: try ID_LIKE tokens
91- for like in ${ID_LIKE:- } ; do
92- case " $like " in
93- ubuntu | debian)
94- echo apt
95- return 0
96- ;;
97- arch | manjaro | artix)
98- echo yay
99- return 0
100- ;;
101- fedora | rhel | centos)
102- echo dnf
103- return 0
104- ;;
105- esac
106- done
107-
108- echo unknown
74+ # Maps distro IDs to a package manager "family": apt | yay | dnf
75+ case " ${ID:- } " in
76+ ubuntu | debian)
77+ echo apt
78+ return 0
79+ ;;
80+ arch | artix | cachyos )
81+ echo yay
82+ return 0
83+ ;;
84+ fedora | rhel | centos)
85+ echo dnf
86+ return 0
87+ ;;
88+ esac
89+
90+ # Fallback: try ID_LIKE tokens
91+ for like in ${ID_LIKE:- } ; do
92+ case " $like " in
93+ ubuntu | debian)
94+ echo apt
95+ return 0
96+ ;;
97+ arch | manjaro | artix)
98+ echo yay
99+ return 0
100+ ;;
101+ fedora | rhel | centos)
102+ echo dnf
103+ return 0
104+ ;;
105+ esac
106+ done
107+
108+ echo unknown
109109}
110110echo " [1/3] Installing CLI packages for '$ID '..."
111111run_cli
@@ -114,31 +114,31 @@ echo "[2/3] Installing dotfiles..."
114114" $BASEDIR /install"
115115
116116if $GUI ; then
117- echo " [3/3] Installing GUI packages for '$ID '..."
118- run_gui
119- if command -v flatpak > /dev/null 2>&1 ; then
120- echo " Installing Flatpak packages..."
121- " $BASEDIR /scripts/flatpak.sh"
122- else
123- echo " Flatpak not found; skipping Flatpak packages."
124- fi
117+ echo " [3/3] Installing GUI packages for '$ID '..."
118+ run_gui
119+ if command -v flatpak > /dev/null 2>&1 ; then
120+ echo " Installing Flatpak packages..."
121+ " $BASEDIR /scripts/flatpak.sh"
122+ else
123+ echo " Flatpak not found; skipping Flatpak packages."
124+ fi
125125
126126else
127- echo " [3/3] Skipping GUI packages (run with -g to include)."
127+ echo " [3/3] Skipping GUI packages (run with -g to include)."
128128fi
129129if command -v systemctl > /dev/null 2>&1 ; then
130- if command -v tailscaled > /dev/null 2>&1 || systemctl list-unit-files --type=service 2> /dev/null | grep -q ' ^tailscaled\.service' ; then
131- echo " Ensuring tailscaled service is enabled and running..."
132- if ! systemctl is-enabled tailscaled > /dev/null 2>&1 || ! systemctl is-active tailscaled > /dev/null 2>&1 ; then
133- if command -v sudo > /dev/null 2>&1 ; then
134- sudo systemctl enable --now tailscaled || true
135- sudo tailscaled set --operator=" $USER "
136- echo " Enabled tailscaled service and set operator to current user."
137- else
138- systemctl enable --now tailscaled || true
139- fi
140- fi
141- fi
130+ if command -v tailscaled > /dev/null 2>&1 || systemctl list-unit-files --type=service 2> /dev/null | grep -q ' ^tailscaled\.service' ; then
131+ echo " Ensuring tailscaled service is enabled and running..."
132+ if ! systemctl is-enabled tailscaled > /dev/null 2>&1 || ! systemctl is-active tailscaled > /dev/null 2>&1 ; then
133+ if command -v sudo > /dev/null 2>&1 ; then
134+ sudo systemctl enable --now tailscaled || true
135+ sudo tailscaled set --operator=" $USER "
136+ echo " Enabled tailscaled service and set operator to current user."
137+ else
138+ systemctl enable --now tailscaled || true
139+ fi
140+ fi
141+ fi
142142fi
143143
144144echo " Done."
0 commit comments