22
33REPO=" https://github.com/0l3d/ffetch.git"
44DIR=" ffetch"
5+ BINARY_PATH=" "
6+ DEFAULT_INSTALL_PATH=" /usr/local/bin"
57
68echo " Select installation method:"
79echo " 1) Build from source (Git version)"
810echo " 2) Download release binary"
9- echo -n " Choice [1-2]: "
11+ echo " 3) Update binary only"
12+ echo " s) Skip installation"
13+ echo -n " Choice [1-3,s]: "
1014read install_choice
1115
1216case " $install_choice " in
@@ -15,40 +19,45 @@ case "$install_choice" in
1519 echo " 1) Balanced (Balanced size & performance)"
1620 echo " 2) Size (Size optimized)"
1721 echo " 3) Performance (Performance optimized)"
18- echo -n " Choice [1-3]: "
22+ echo " s) Skip build"
23+ echo -n " Choice [1-3,s]: "
1924 read choice
2025
21- if [ -d " $DIR " ]; then
22- cd " $DIR "
23- git pull
26+ if [ " $choice " = " s " ]; then
27+ echo " Skipping build step. "
28+ BINARY_PATH= " "
2429 else
25- git clone --depth=1 " $REPO " " $DIR "
26- cd " $DIR "
30+ if [ -d " $DIR " ]; then
31+ cd " $DIR "
32+ git pull
33+ else
34+ git clone --depth=1 " $REPO " " $DIR "
35+ cd " $DIR "
36+ fi
37+
38+ case " $choice " in
39+ 1) cargo build --release ;;
40+ 2) cargo build --profile size ;;
41+ 3) cargo build --profile performance ;;
42+ * ) echo " Invalid build profile" ; exit 1 ;;
43+ esac
44+
45+ if [ " $choice " -eq 1 ]; then
46+ profile_dir=" release"
47+ elif [ " $choice " -eq 2 ]; then
48+ profile_dir=" size"
49+ elif [ " $choice " -eq 3 ]; then
50+ profile_dir=" performance"
51+ fi
52+
53+ BINARY_PATH=" $( pwd) /target/$profile_dir /ffetch"
54+ echo " Build complete: $BINARY_PATH "
55+ cd ..
2756 fi
28-
29- case " $choice " in
30- 1) cargo build --release ;;
31- 2) cargo build --profile size ;;
32- 3) cargo build --profile performance ;;
33- * ) echo " Invalid build profile" ; exit 1 ;;
34- esac
35-
36- if [ " $choice " -eq 1 ]; then
37- profile_dir=" release"
38- elif [ " $choice " -eq 2 ]; then
39- profile_dir=" size"
40- elif [ " $choice " -eq 3 ]; then
41- profile_dir=" performance"
42- fi
43-
44- BINARY_PATH=" $( pwd) /target/$profile_dir /ffetch"
45- echo " Build complete: $BINARY_PATH "
46- cd ..
4757 ;;
4858
4959 2)
5060 echo " Downloading latest release binary..."
51-
5261 DOWNLOAD_URL=$( curl -s https://api.github.com/repos/0l3d/ffetch/releases/latest \
5362 | grep -oP ' "browser_download_url": "\K[^"]*ffetch-[^"]+-linux[^"]+\.tar\.gz' )
5463
@@ -65,73 +74,118 @@ case "$install_choice" in
6574 echo " Download complete: $BINARY_PATH "
6675 rm ffetch.tar.gz
6776
68- git clone " $REPO " " $DIR "
77+ if [ ! -d " $DIR " ]; then
78+ git clone " $REPO " " $DIR "
79+ fi
80+ ;;
81+
82+ 3)
83+ echo " Updating binary only..."
84+ DOWNLOAD_URL=$( curl -s https://api.github.com/repos/0l3d/ffetch/releases/latest \
85+ | grep -oP ' "browser_download_url": "\K[^"]*ffetch-[^"]+-linux[^"]+\.tar\.gz' )
86+
87+ if [ -z " $DOWNLOAD_URL " ]; then
88+ echo " Error: Could not find release download URL."
89+ exit 1
90+ fi
91+
92+ echo " Download URL: $DOWNLOAD_URL "
93+ curl -L " $DOWNLOAD_URL " -o ffetch.tar.gz
94+ tar -xzf ffetch.tar.gz
95+ chmod +x ffetch
96+ BINARY_PATH=" $( pwd) /ffetch"
97+ echo " Update complete: $BINARY_PATH "
98+ rm ffetch.tar.gz
99+ ;;
100+
101+ s|S)
102+ echo " Skipping installation step."
103+ BINARY_PATH=" "
69104 ;;
105+
70106 * )
71107 echo " Invalid choice"
72108 exit 1
73109 ;;
74110esac
75111
76- echo " "
77- echo " Setting up configuration..."
78- mkdir -p ~ /.config/ffetch
79-
80- echo " Select configuration profile:"
81- echo " 1) Advanced"
82- echo " 2) Middle"
83- echo " 3) Minimal"
84- echo -n " Choice [1-3]: "
85- read config_choice
86-
87- case " $config_choice " in
88- 1) CONFIG_FILE=" ffetch-advanced.conf" ;;
89- 2) CONFIG_FILE=" ffetch-middle.conf" ;;
90- 3) CONFIG_FILE=" ffetch-minimal.conf" ;;
91- * ) CONFIG_FILE=" ffetch-middle.conf" ;;
92- esac
93-
94- if [ -f " $CONFIG_FILE " ]; then
95- cp " $CONFIG_FILE " ~ /.config/ffetch/ffetch.conf
96- elif [ -f " $DIR /$CONFIG_FILE " ]; then
97- cp " $DIR /$CONFIG_FILE " ~ /.config/ffetch/ffetch.conf
98- else
99- echo " Warning: Configuration file not found"
112+ if [ -z " $BINARY_PATH " ]; then
113+ echo " No binary built or downloaded. Exiting."
114+ exit 0
100115fi
101116
102- echo " "
103- echo " Fetching ASCII art list from remote repository..."
104- ASCII_LIST=$( curl -s https://api.github.com/repos/0l3d/ffetch/contents/ascii | grep ' "name":' | cut -d ' "' -f 4)
105-
106- if [ -z " $ASCII_LIST " ]; then
107- echo " No ASCII files found in remote repo."
108- else
109- mapfile -t ascii_array <<< " $ASCII_LIST"
110- for i in " ${! ascii_array[@]} " ; do
111- name=$( basename " ${ascii_array[$i]} " .txt)
112- echo " $(( i+ 1 )) ) $name "
113- done
114-
115- echo -n " Select ASCII art [1-${# ascii_array[@]} ]: "
116- read ascii_choice
117-
118- if [[ " $ascii_choice " =~ ^[0-9]+$ ]] && [ " $ascii_choice " -ge 1 ] && [ " $ascii_choice " -le " ${# ascii_array[@]} " ]; then
119- ascii_file=" ${ascii_array[$((ascii_choice - 1))]} "
120- curl -s -L " https://raw.githubusercontent.com/0l3d/ffetch/master/ascii/$ascii_file " -o ~ /.config/ffetch/ascii.txt
121- echo " ASCII art saved to ~/.config/ffetch/ascii.txt"
117+ if [ " $install_choice " = " 1" ] || [ " $install_choice " = " 2" ]; then
118+ echo " "
119+ echo " Setting up configuration..."
120+ mkdir -p ~ /.config/ffetch
121+
122+ echo " Select configuration profile:"
123+ echo " 1) Advanced"
124+ echo " 2) Middle"
125+ echo " 3) Minimal"
126+ echo " s) Skip configuration"
127+ echo -n " Choice [1-3,s]: "
128+ read config_choice
129+
130+ case " $config_choice " in
131+ 1) CONFIG_FILE=" ffetch-advanced.conf" ;;
132+ 2) CONFIG_FILE=" ffetch-middle.conf" ;;
133+ 3) CONFIG_FILE=" ffetch-minimal.conf" ;;
134+ s|S) CONFIG_FILE=" " ;;
135+ * ) CONFIG_FILE=" ffetch-middle.conf" ;;
136+ esac
137+
138+ if [ -n " $CONFIG_FILE " ]; then
139+ if [ -f " $CONFIG_FILE " ]; then
140+ cp " $CONFIG_FILE " ~ /.config/ffetch/ffetch.conf
141+ elif [ -f " $DIR /$CONFIG_FILE " ]; then
142+ cp " $DIR /$CONFIG_FILE " ~ /.config/ffetch/ffetch.conf
143+ else
144+ echo " Warning: Configuration file not found"
145+ fi
122146 else
123- echo " Invalid choice. Skipping ASCII art."
147+ echo " Skipping configuration setup."
148+ fi
149+
150+ echo " "
151+ echo " Fetching ASCII art list from remote repository..."
152+ ASCII_LIST=$( curl -s https://api.github.com/repos/0l3d/ffetch/contents/ascii | grep ' "name":' | cut -d ' "' -f 4)
153+
154+ if [ -z " $ASCII_LIST " ]; then
155+ echo " No ASCII files found in remote repo."
156+ else
157+ mapfile -t ascii_array <<< " $ASCII_LIST"
158+ for i in " ${! ascii_array[@]} " ; do
159+ name=$( basename " ${ascii_array[$i]} " .txt)
160+ echo " $(( i+ 1 )) ) $name "
161+ done
162+
163+ echo -n " Select ASCII art [1-${# ascii_array[@]} ] or s to skip: "
164+ read ascii_choice
165+
166+ if [[ " $ascii_choice " =~ ^[0-9]+$ ]] && [ " $ascii_choice " -ge 1 ] && [ " $ascii_choice " -le " ${# ascii_array[@]} " ]; then
167+ ascii_file=" ${ascii_array[$((ascii_choice - 1))]} "
168+ curl -s -L " https://raw.githubusercontent.com/0l3d/ffetch/master/ascii/$ascii_file " -o ~ /.config/ffetch/ascii.txt
169+ echo " ASCII art saved to ~/.config/ffetch/ascii.txt"
170+ else
171+ echo " Skipping ASCII art selection."
172+ fi
124173 fi
125174fi
126175
127176echo " "
128- echo -n " Move ffetch to /usr/local/bin? [y/N]: "
177+ echo -n " Move ffetch binary to /usr/local/bin or specify path? (default: /usr/local/bin) [y/N/path ]: "
129178read move_binary
130179
131180case " $move_binary " in
132181 [Yy]* )
133- sudo cp " $BINARY_PATH " /usr/local/bin/ffetch
134- echo " ffetch moved to /usr/local/bin/"
182+ sudo cp " $BINARY_PATH " " $DEFAULT_INSTALL_PATH /ffetch"
183+ echo " ffetch moved to $DEFAULT_INSTALL_PATH /"
184+ echo " You can now run: ffetch"
185+ ;;
186+ /* )
187+ sudo cp " $BINARY_PATH " " $move_binary /ffetch"
188+ echo " ffetch moved to $move_binary /"
135189 echo " You can now run: ffetch"
136190 ;;
137191 * )
0 commit comments