Skip to content

Commit 3430aca

Browse files
committed
pakcage managers, fixes, improvements, etc.
1 parent 3ccff52 commit 3430aca

File tree

12 files changed

+268
-8
lines changed

12 files changed

+268
-8
lines changed

README.md

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,29 +100,79 @@ mv tum your_desired_location/
100100

101101
### UNIX:
102102

103-
```perl
103+
```bash
104104
#!/bin/bash
105105

106-
source tum
106+
source unix.sh
107107

108+
DISTRO=$(get_user_distro)
109+
echo -e "${GREEN}Detected distribution: ${DISTRO}${RESET}"
110+
111+
if macos_based "$DISTRO" "$MACOS_BASED"; then
112+
echo -e "${GREEN}This is a macOS-based system.${RESET}"
113+
else
114+
echo -e "${GREEN}This is NOT a macOS-based system.${RESET}"
115+
fi
116+
117+
INIT_SYSTEM=$(get_init_system)
118+
echo -e "${GREEN}Detected init system: ${INIT_SYSTEM}${RESET}"
108119
```
109120

110121
### Service Management:
111122

112-
```perl
123+
```bash
113124
#!/bin/bash
114125

115-
source tum
126+
source sysvinit.sh
127+
128+
SERVICE_NAME="ssh"
129+
130+
echo -e "${GREEN}Starting service '$SERVICE_NAME'...${RESET}"
131+
start_service "$SERVICE_NAME"
132+
133+
echo -e "${GREEN}Checking status of service '$SERVICE_NAME'...${RESET}"
134+
status_service "$SERVICE_NAME"
135+
136+
echo -e "${GREEN}Restarting service '$SERVICE_NAME' using execute_service function...${RESET}"
137+
execute_service restart "$SERVICE_NAME"
138+
139+
echo -e "${GREEN}Stopping service '$SERVICE_NAME'...${RESET}"
140+
stop_service "$SERVICE_NAME"
116141

142+
echo -e "${GREEN}Trying unknown command with execute_service...${RESET}"
143+
execute_service foobar "$SERVICE_NAME"
117144
```
118145

119146
### Package Management
120147

121-
```perl
148+
```bash
122149
#!/bin/bash
123150

124-
source tum
151+
source apk.sh
152+
153+
echo "=== Display apk version ==="
154+
apk_version
155+
156+
echo -e "\n=== Show apk help ==="
157+
apk_help
158+
159+
echo -e "\n=== Update package index ==="
160+
apk_update
161+
162+
echo -e "\n=== Search for package 'bash' ==="
163+
apk_search bash
164+
165+
echo -e "\n=== Show info about package 'bash' ==="
166+
apk_info bash
167+
168+
echo -e "\n=== List installed packages ==="
169+
apk_list
170+
171+
echo -e "\n=== Add package 'curl' (dry-run) ==="
172+
apk_add --simulate curl
125173

174+
echo -e "\n=== Remove package 'curl' (dry-run) ==="
175+
apk_del --simulate curl
126176
```
127177

128178
## Other Implementations by Archetypum
@@ -139,7 +189,7 @@ source tum
139189

140190
## Legal
141191

142-
**tum-perl** is free software, released under the **GNU Lesser General Public License v3**.
192+
**tum-bash** is free software, released under the **GNU Lesser General Public License v3**.
143193

144194
See:
145195

lib/init_system/openrc.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
declare -r RED="\033[0;31m"
4+
declare -r GREEN="\033[0;32m"
5+
declare -r RESET="\033[0m"
6+
37
function _run_rc_service()
48
{
59
local ACTION="$1"

lib/init_system/runit.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
declare -r RED="\033[0;31m"
4+
declare -r GREEN="\033[0;32m"
5+
declare -r RESET="\033[0m"
6+
37
function _run_sv()
48
{
59
local ACTION="$1"

lib/init_system/s6.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
declare -r RED="\033[0;31m"
4+
declare -r GREEN="\033[0;32m"
5+
declare -r RESET="\033[0m"
6+
37
function _run_s6_rc()
48
{
59
local ACTION="$1"

lib/init_system/systemd.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
declare -r RED="\033[0;31m"
4+
declare -r GREEN="\033[0;32m"
5+
declare -r RESET="\033[0m"
6+
37
function _run_systemctl()
48
{
59
local ACTION="$1"

lib/init_system/sysvinit.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/bin/bash
22

3+
declare -r RED="\033[0;31m"
4+
declare -r GREEN="\033[0;32m"
5+
declare -r RESET="\033[0m"
6+
37
function _run_service()
48
{
59
local ACTION="$1"

lib/package_manager/qi.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
declare -r RED="\033[0;31m"
4+
declare -r GREEN="\033[0;32m"
5+
declare -r RESET="\033[0m"
6+
7+
function execute()
8+
{
9+
local CMD=("$@")
10+
echo -e "${GREEN}[<==] Executing '${CMD[*]}'...${RESET}"
11+
if "${CMD[@]}"; then
12+
echo -e "${GREEN}[*] Success!${RESET}"
13+
return 0
14+
else
15+
echo -e "${RED}[!] Error: Failed to execute: '${CMD[*]}'.${RESET}"
16+
return 1
17+
fi
18+
}
19+
20+
function qi() { execute qi "$@"; }
21+
function qi_warn() { execute qi warn "$@"; }
22+
function qi_install() { execute qi install "$@"; }
23+
function qi_remove() { execute qi remove "$@"; }
24+
function qi_upgrade() { execute qi upgrade "$@"; }
25+
function qi_extract() { execute qi extract "$@"; }
26+
function qi_create() { execute qi create "$@"; }
27+
function qi_build() { execute qi build "$@"; }
28+
function qi_order() { execute qi order "$@"; }
29+

lib/package_manager/slackpkg.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
declare -r RED="\033[0;31m"
4+
declare -r GREEN="\033[0;32m"
5+
declare -r RESET="\033[0m"
6+
7+
function execute()
8+
{
9+
local CMD=("$@")
10+
echo -e "${GREEN}[<==] Executing '${CMD[*]}'...${RESET}"
11+
if "${CMD[@]}"; then
12+
echo -e "${GREEN}[*] Success!${RESET}"
13+
return 0
14+
else
15+
echo -e "${RED}[!] Error: Failed to execute: '${CMD[*]}'${RESET}"
16+
return 1
17+
fi
18+
}
19+
20+
function slackpkg() { execute slackpkg "$@"; }
21+
function slackpkg_search() { execute slackpkg search "$@"; }
22+
function slackpkg_install() { execute slackpkg install "$@"; }
23+
function slackpkg_upgrade() { execute slackpkg upgrade "$@"; }
24+
function slackpkg_reinstall() { execute slackpkg reinstall "$@"; }
25+
function slackpkg_remove() { execute slackpkg remove "$@"; }
26+
function slackpkg_blacklist() { execute slackpkg blacklist "$@"; }
27+
function slackpkg_download() { execute slackpkg download "$@"; }
28+
function slackpkg_info() { execute slackpkg info "$@"; }
29+
function slackpkg_clean_system() { execute slackpkg clean-system "$@"; }
30+
function slackpkg_upgrade_all() { execute slackpkg upgrade-all "$@"; }
31+
function slackpkg_install_new() { execute slackpkg install-new "$@"; }
32+
function slackpkg_check_updates() { execute slackpkg check-updates "$@"; }
33+
function slackpkg_update() { execute slackpkg update "$@"; }

lib/package_manager/xbps_query.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
declare -r RED="\033[0;31m"
4+
declare -r GREEN="\033[0;32m"
5+
declare -r RESET="\033[0m"
6+
7+
function execute()
8+
{
9+
local CMD=("$@")
10+
echo -e "${GREEN}[<==] Executing '${CMD[*]}'...${RESET}"
11+
if "${CMD[@]}"; then
12+
echo -e "${GREEN}[*] Success!${RESET}"
13+
return 0
14+
else
15+
echo -e "${RED}[!] Error: Failed to execute: '${CMD[*]}'${RESET}"
16+
return 1
17+
fi
18+
}
19+
20+
function xbps_query() { execute xbps-query "$@"; }
21+
function xbps_query_list_pkgs() { execute xbps-query --list-pkgs "$@"; }
22+
function xbps_query_list_hold_pkgs() { execute xbps-query --list-hold-pkgs "$@"; }
23+
function xbps_query_list_repos() { execute xbps-query --list-repos "$@"; }
24+
function xbps_query_list_manual_pkgs() { execute xbps-query --list-manual-pkgs "$@"; }
25+
function xbps_query_list_orphans() { execute xbps-query --list-orphans "$@"; }
26+
function xbps_query_ownedby() { execute xbps-query --ownedby "$@"; }
27+
function xbps_query_show() { execute xbps-query --show "$@"; }
28+
function xbps_query_search() { execute xbps-query --search "$@"; }
29+
function xbps_query_files() { execute xbps-query --files "$@"; }
30+
function xbps_query_deps() { execute xbps-query --deps "$@"; }
31+
function xbps_query_revdeps() { execute xbps-query --revdeps "$@"; }
32+
function xbps_query_cat() { execute xbps-query cat "$@"; }
33+

lib/package_manager/xbps_remove.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
declare -r RED="\033[0;31m"
4+
declare -r GREEN="\033[0;32m"
5+
declare -r RESET="\033[0m"
6+
7+
function execute()
8+
{
9+
local CMD=("$@")
10+
echo -e "${GREEN}[<==] Executing '${CMD[*]}'...${RESET}"
11+
if "${CMD[@]}"; then
12+
echo -e "${GREEN}[*] Success!${RESET}"
13+
return 0
14+
else
15+
echo -e "${RED}[!] Error: Failed to execute: '${CMD[*]}'.${RESET}"
16+
return 1
17+
fi
18+
}
19+
20+
function xbps_remove() { execute xbps-remove "$@"; }
21+

0 commit comments

Comments
 (0)