Skip to content

Commit eb5b658

Browse files
authored
Update version to 0.1.8 and enhance menu options
1 parent 0e1c273 commit eb5b658

1 file changed

Lines changed: 32 additions & 18 deletions

File tree

rom.sh

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
# ==============================================================================
88

99
# --- Settings and Colors ---
10-
VERSION="0.1.7"
11-
REPO_URL="https://api.github.com/repos/diogopessoa/rpm-ostree-manager/releases/latest"
10+
VERSION="0.1.8"
11+
REPO_API_URL="https://api.github.com/repos/diogopessoa/rpm-ostree-manager/releases"
1212
REAL_USER=${SUDO_USER:-$USER}
1313
USER_HOME=$(getent passwd "$REAL_USER" | cut -d: -f6)
1414
DOWNLOADS_DIR="$USER_HOME/Downloads"
15+
16+
# Colors
1517
GREEN='\033[0;32m'
1618
BLUE='\033[0;34m'
1719
RED='\033[0;31m'
@@ -31,12 +33,12 @@ if [[ ! -t 0 ]]; then
3133
fi
3234

3335
check_update() {
34-
# Get the latest version (timeout of 2s to avoid crashing the script)
35-
LATEST_VERSION=$(curl -s --connect-timeout 2 "$REPO_URL" | jq -r '.tag_name' 2>/dev/null | sed 's/v//')
36+
# Fetches the first tag from the releases list to avoid cache issues
37+
LATEST_VERSION=$(curl -s --connect-timeout 2 "$REPO_API_URL" | jq -r '.[0].tag_name' 2>/dev/null | sed 's/v//' | xargs)
3638

3739
if [[ -n "$LATEST_VERSION" && "$LATEST_VERSION" != "null" ]]; then
3840
if [[ "$LATEST_VERSION" != "$VERSION" ]]; then
39-
echo -e "${PURPLE}${BOLD}New version available: v$LATEST_VERSION${NC}"
41+
echo -e "${PURPLE}${BOLD}New version available: v$LATEST_VERSION${NC}"
4042
echo -e "${PURPLE}Update at: github.com/diogopessoa/rpm-ostree-manager${NC}\n"
4143
else
4244
echo -e "${GREEN}✔ System up to date${NC}\n"
@@ -47,24 +49,34 @@ check_update() {
4749
show_menu() {
4850
clear
4951
echo -e "${BLUE}╭────────────────────────────────────╮${NC}"
50-
echo -e "${GREEN} ${BOLD}RPM-OSTree Manager${NC}"
52+
echo -e "${GREEN} ${BOLD}RPM-OSTree Manager${NC}"
5153
echo -e "${BLUE}${NC}v$VERSION${BLUE}${NC}"
5254
echo -e "${BLUE}╰────────────────────────────────────╯${NC}\n"
5355
echo -e "Welcome!"
5456
echo -e "\nChoose an option:"
55-
echo -e "1) ${BLUE}Install${NC} Local RPM (Downloads)"
56-
echo -e "2) ${RED}Remove${NC} Layered/Local RPM"
57-
echo -e "3) ${GREEN}Rollback:${NC} revert the system"
58-
echo -e "4) ${PURPLE}Pin/Unpin${NC} Deployment"
59-
echo -e "5) ${CYAN}Switch Default Deployment${NC}"
60-
echo -e "6) Check Status"
61-
echo -e "7) Documentation & Help"
62-
echo -e "0) Exit"
57+
echo -e ""
58+
echo -e "1) 📦 ${BLUE}Install${NC} Local RPM (Downloads)"
59+
echo -e ""
60+
echo -e "2) 🗑️ ${RED}Remove${NC} Layered/Local RPM"
61+
echo -e ""
62+
echo -e "3) ↩️ ${GREEN}Rollback:${NC} revert the system"
63+
echo ""
64+
echo -e "4) 📌 ${PURPLE}Pin/Unpin${NC} Deployment"
65+
echo ""
66+
echo -e "5) ⚓ ${CYAN}Switch Default Deployment${NC}"
67+
echo -e ""
68+
echo -e "6) ☑️ Check Status"
69+
echo -e ""
70+
echo -e "7) 🛟 Documentation & Help"
71+
echo -e ""
72+
echo -e "0) ✖️ Exit"
73+
echo -e ""
6374
echo -ne "\nOption: "
6475
}
6576

6677
install_rpm() {
6778
echo -e "\n--- ${BLUE}Install Local RPM${NC} ---"
79+
echo -e ""
6880
cd "$DOWNLOADS_DIR" || return
6981

7082
# List .rpm files and store in an array
@@ -104,8 +116,8 @@ install_rpm() {
104116

105117
remove_rpm() {
106118
echo -e "\n--- ${RED}Remove Layered / Local RPM${NC} ---"
107-
echo "Searching for packages..."
108-
119+
echo -e ""
120+
109121
# Searches all possible keys store packages
110122
packages=$(rpm-ostree status --json | jq -r '.deployments[] | select(.booted == true) |
111123
(.packages // []) +
@@ -143,6 +155,7 @@ remove_rpm() {
143155

144156
rollback() {
145157
echo -e "\n--- ${GREEN}System Rollback${NC} ---"
158+
echo -e ""
146159
read -p "Do you want to revert to the previous state? (y/N): " confirm
147160

148161
if [[ "$confirm" =~ ^[Yy]$ ]]; then
@@ -163,7 +176,7 @@ rollback() {
163176

164177
pin_manager() {
165178
echo -e "\n--- ${PURPLE}Pin/Unpin Deployment Manager${NC} ---"
166-
echo "Fetching deployments..."
179+
# echo "Fetching deployments..."
167180

168181
# Extracts version and state from 'pinned'
169182
mapfile -t deploy_data < <(rpm-ostree status --json | jq -r '.deployments[] | "\(.version)|\(.pinned)"')
@@ -228,7 +241,8 @@ pin_manager() {
228241
}
229242

230243
switch_default_deployment() {
231-
echo -e "\n--- ${BOLD}Switch Default Deployment${NC} ---"
244+
echo -e "\n--- ${CYAN}Switch Default Deployment${NC} ---"
245+
echo -e ""
232246
echo "Select which deployment should be the default for the next boot:"
233247

234248
mapfile -t deployments < <(rpm-ostree status --json | jq -r '.deployments[].version')

0 commit comments

Comments
 (0)