underpost 2.92.0 → 2.95.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/pwa-microservices-template-page.cd.yml +5 -4
- package/README.md +4 -5
- package/bin/build.js +6 -1
- package/bin/deploy.js +2 -69
- package/cli.md +100 -92
- package/manifests/deployment/dd-default-development/deployment.yaml +4 -4
- package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
- package/package.json +1 -1
- package/scripts/disk-clean.sh +216 -0
- package/scripts/ssh-cluster-info.sh +4 -3
- package/src/cli/cluster.js +1 -1
- package/src/cli/db.js +80 -89
- package/src/cli/deploy.js +77 -13
- package/src/cli/image.js +198 -133
- package/src/cli/index.js +60 -81
- package/src/cli/lxd.js +73 -74
- package/src/cli/monitor.js +20 -9
- package/src/cli/repository.js +86 -3
- package/src/cli/run.js +167 -63
- package/src/cli/ssh.js +351 -134
- package/src/index.js +1 -1
- package/src/monitor.js +11 -1
- package/src/server/backup.js +1 -1
- package/src/server/conf.js +1 -1
- package/src/server/dns.js +88 -1
- package/src/server/process.js +6 -1
- package/scripts/snap-clean.sh +0 -26
- package/src/client/public/default/plantuml/client-conf.svg +0 -1
- package/src/client/public/default/plantuml/client-schema.svg +0 -1
- package/src/client/public/default/plantuml/cron-conf.svg +0 -1
- package/src/client/public/default/plantuml/cron-schema.svg +0 -1
- package/src/client/public/default/plantuml/server-conf.svg +0 -1
- package/src/client/public/default/plantuml/server-schema.svg +0 -1
- package/src/client/public/default/plantuml/ssr-conf.svg +0 -1
- package/src/client/public/default/plantuml/ssr-schema.svg +0 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# disk-clean.sh
|
|
3
|
+
# Safe, interactive disk cleanup for Rocky/RHEL-like systems.
|
|
4
|
+
|
|
5
|
+
set -u # Detect undefined variables (removed -e to handle errors manually where it matters)
|
|
6
|
+
IFS=$'\n\t'
|
|
7
|
+
|
|
8
|
+
AUTO_YES=0
|
|
9
|
+
LXD_FLAG=0
|
|
10
|
+
VACUUM_SIZE="500M"
|
|
11
|
+
TMP_AGE_DAYS=7
|
|
12
|
+
LOG_GZ_AGE_DAYS=90
|
|
13
|
+
ROOT_CACHE_AGE_DAYS=30
|
|
14
|
+
AGGRESSIVE=0
|
|
15
|
+
|
|
16
|
+
# Colors for better readability
|
|
17
|
+
RED='\033[0;31m'
|
|
18
|
+
GREEN='\033[0;32m'
|
|
19
|
+
YELLOW='\033[1;33m'
|
|
20
|
+
NC='\033[0m' # No Color
|
|
21
|
+
|
|
22
|
+
usage() {
|
|
23
|
+
cat <<EOF
|
|
24
|
+
Usage: $0 [--yes] [--aggressive] [--lxd] [--vacuum-size SIZE]
|
|
25
|
+
|
|
26
|
+
Options:
|
|
27
|
+
--yes run destructive actions without asking
|
|
28
|
+
--aggressive clean user caches (npm, pip, conda, root .cache)
|
|
29
|
+
--lxd enable lxc image prune
|
|
30
|
+
--vacuum-size X set journalctl --vacuum-size (default: $VACUUM_SIZE)
|
|
31
|
+
-h, --help show this help
|
|
32
|
+
EOF
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# Parse args
|
|
36
|
+
while [[ $# -gt 0 ]]; do
|
|
37
|
+
case "$1" in
|
|
38
|
+
--yes) AUTO_YES=1; shift;;
|
|
39
|
+
--aggressive) AGGRESSIVE=1; shift;;
|
|
40
|
+
--lxd) LXD_FLAG=1; shift;;
|
|
41
|
+
--vacuum-size) VACUUM_SIZE="$2"; shift 2;;
|
|
42
|
+
-h|--help) usage; exit 0;;
|
|
43
|
+
*) echo "Unknown argument: $1"; usage; exit 2;;
|
|
44
|
+
esac
|
|
45
|
+
done
|
|
46
|
+
|
|
47
|
+
log() { echo -e "${GREEN}[INFO]${NC} $*"; }
|
|
48
|
+
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
|
|
49
|
+
error() { echo -e "${RED}[ERROR]${NC} $*"; }
|
|
50
|
+
|
|
51
|
+
run() {
|
|
52
|
+
# Runs the command safely
|
|
53
|
+
echo "+ $*"
|
|
54
|
+
# Execute the command passed as arguments, preserving quotes/spaces
|
|
55
|
+
"$@" || {
|
|
56
|
+
warn "Command failed (non-critical): $*"
|
|
57
|
+
return 0
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
confirm() {
|
|
62
|
+
if [[ $AUTO_YES -eq 1 ]]; then
|
|
63
|
+
return 0
|
|
64
|
+
fi
|
|
65
|
+
# Use </dev/tty to ensure we read from user even inside a pipe loop
|
|
66
|
+
read -r -p "$1 [y/N]: " ans </dev/tty
|
|
67
|
+
case "$ans" in
|
|
68
|
+
[Yy]|[Yy][Ee][Ss]) return 0;;
|
|
69
|
+
*) return 1;;
|
|
70
|
+
esac
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
require_root() {
|
|
74
|
+
if [[ $EUID -ne 0 ]]; then
|
|
75
|
+
error "This script must be run as root."
|
|
76
|
+
exit 1
|
|
77
|
+
fi
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
command_exists() {
|
|
81
|
+
command -v "$1" >/dev/null 2>&1
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
require_root
|
|
85
|
+
|
|
86
|
+
log "Starting cleanup (aggressive=$AGGRESSIVE)"
|
|
87
|
+
|
|
88
|
+
# 1) Package Manager (DNF)
|
|
89
|
+
if command_exists dnf; then
|
|
90
|
+
log "Cleaning DNF caches"
|
|
91
|
+
run dnf clean all
|
|
92
|
+
run rm -rf /var/cache/dnf
|
|
93
|
+
if confirm "Run 'dnf autoremove -y' for orphan packages?"; then
|
|
94
|
+
run dnf autoremove -y
|
|
95
|
+
else
|
|
96
|
+
log "Skipped dnf autoremove"
|
|
97
|
+
fi
|
|
98
|
+
else
|
|
99
|
+
warn "dnf not found"
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
# 2) Journal logs
|
|
103
|
+
if command_exists journalctl; then
|
|
104
|
+
log "Current Journal disk usage:"
|
|
105
|
+
journalctl --disk-usage || true
|
|
106
|
+
|
|
107
|
+
if confirm "Run 'journalctl --vacuum-size=$VACUUM_SIZE'?"; then
|
|
108
|
+
run journalctl --vacuum-size="$VACUUM_SIZE"
|
|
109
|
+
else
|
|
110
|
+
log "Skipped journal vacuum"
|
|
111
|
+
fi
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
# 3) /var/tmp
|
|
115
|
+
if [[ -d /var/tmp ]]; then
|
|
116
|
+
if confirm "Delete files in /var/tmp older than $TMP_AGE_DAYS days?"; then
|
|
117
|
+
find /var/tmp -mindepth 1 -mtime +$TMP_AGE_DAYS -delete
|
|
118
|
+
fi
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
# 4) Old compressed logs
|
|
122
|
+
if [[ -d /var/log ]]; then
|
|
123
|
+
if confirm "Delete compressed logs (.gz) in /var/log older than $LOG_GZ_AGE_DAYS days?"; then
|
|
124
|
+
find /var/log -type f -name '*.gz' -mtime +$LOG_GZ_AGE_DAYS -delete
|
|
125
|
+
fi
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
# 5) Snap: disabled revisions
|
|
129
|
+
if command_exists snap; then
|
|
130
|
+
log "Searching for old Snap revisions"
|
|
131
|
+
# Save to variable only if successful
|
|
132
|
+
disabled_snaps=$(snap list --all 2>/dev/null | awk '/disabled/ {print $1, $3}') || disabled_snaps=""
|
|
133
|
+
|
|
134
|
+
if [[ -n "$disabled_snaps" ]]; then
|
|
135
|
+
echo "Disabled snap revisions found:"
|
|
136
|
+
echo "$disabled_snaps"
|
|
137
|
+
if confirm "Remove all disabled revisions?"; then
|
|
138
|
+
while read -r pkg rev; do
|
|
139
|
+
[[ -z "$pkg" ]] && continue
|
|
140
|
+
log "Removing snap $pkg (revision $rev)"
|
|
141
|
+
run snap remove "$pkg" --revision="$rev"
|
|
142
|
+
done <<< "$disabled_snaps"
|
|
143
|
+
|
|
144
|
+
log "Setting snap retention to 2"
|
|
145
|
+
run snap set system refresh.retain=2
|
|
146
|
+
fi
|
|
147
|
+
else
|
|
148
|
+
log "No disabled snap revisions found."
|
|
149
|
+
fi
|
|
150
|
+
fi
|
|
151
|
+
|
|
152
|
+
# 6) LXD
|
|
153
|
+
if command_exists lxc; then
|
|
154
|
+
if [[ $LXD_FLAG -eq 1 ]]; then
|
|
155
|
+
if confirm "Run 'lxc image prune'?"; then
|
|
156
|
+
run lxc image prune -f
|
|
157
|
+
fi
|
|
158
|
+
else
|
|
159
|
+
log "Skipping LXD (use --lxd to enable)"
|
|
160
|
+
fi
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
# 7) Docker / Containerd
|
|
164
|
+
if command_exists docker; then
|
|
165
|
+
if confirm "Run 'docker system prune -a --volumes'? (WARNING: Removes stopped containers)"; then
|
|
166
|
+
run docker system prune -a --volumes -f
|
|
167
|
+
fi
|
|
168
|
+
elif command_exists crictl; then
|
|
169
|
+
if confirm "Attempt to remove images with crictl?"; then
|
|
170
|
+
run crictl rmi --prune
|
|
171
|
+
fi
|
|
172
|
+
fi
|
|
173
|
+
|
|
174
|
+
# 8) Large Files (>1G) - Completely rewritten logic
|
|
175
|
+
log "Scanning for files larger than 1G (this may take a while)..."
|
|
176
|
+
|
|
177
|
+
# Use while loop with find -print0 to handle filenames with spaces safely
|
|
178
|
+
FOUND_LARGE=0
|
|
179
|
+
# Note: find does not modify filesystem here, safe to run always
|
|
180
|
+
while IFS= read -r -d '' file; do
|
|
181
|
+
FOUND_LARGE=1
|
|
182
|
+
# Get readable size to show user
|
|
183
|
+
filesize=$(du -h "$file" | cut -f1)
|
|
184
|
+
|
|
185
|
+
echo -e "Large file found: ${YELLOW}$file${NC} (Size: $filesize)"
|
|
186
|
+
|
|
187
|
+
if confirm " -> Delete this file?"; then
|
|
188
|
+
run rm -vf "$file"
|
|
189
|
+
else
|
|
190
|
+
log "Skipped: $file"
|
|
191
|
+
fi
|
|
192
|
+
done < <(find / -xdev -type f -size +1G -print0 2>/dev/null)
|
|
193
|
+
|
|
194
|
+
if [[ $FOUND_LARGE -eq 0 ]]; then
|
|
195
|
+
log "No files >1G found in /"
|
|
196
|
+
fi
|
|
197
|
+
|
|
198
|
+
# 9) Aggressive Caches
|
|
199
|
+
if [[ $AGGRESSIVE -eq 1 ]]; then
|
|
200
|
+
log "Aggressive mode enabled"
|
|
201
|
+
command_exists npm && confirm "Run 'npm cache clean --force'?" && run npm cache clean --force
|
|
202
|
+
command_exists pip && confirm "Run 'pip cache purge'?" && run pip cache purge
|
|
203
|
+
command_exists conda && confirm "Run 'conda clean --all -y'?" && run conda clean --all -y
|
|
204
|
+
|
|
205
|
+
if [[ -d /root/.cache ]]; then
|
|
206
|
+
if confirm "Delete /root/.cache (> $ROOT_CACHE_AGE_DAYS days)?"; then
|
|
207
|
+
find /root/.cache -type f -mtime +$ROOT_CACHE_AGE_DAYS -delete
|
|
208
|
+
fi
|
|
209
|
+
fi
|
|
210
|
+
fi
|
|
211
|
+
|
|
212
|
+
# 10) Final
|
|
213
|
+
log "Final disk usage:"
|
|
214
|
+
df -h --total | grep total || df -h /
|
|
215
|
+
|
|
216
|
+
log "Cleanup finished."
|
|
@@ -3,12 +3,13 @@ set -euo pipefail
|
|
|
3
3
|
|
|
4
4
|
REMOTE_USER=$(node bin config get --plain DEFAULT_SSH_USER)
|
|
5
5
|
REMOTE_HOST=$(node bin config get --plain DEFAULT_SSH_HOST)
|
|
6
|
+
REMOTE_PORT=$(node bin config get --plain DEFAULT_SSH_PORT)
|
|
6
7
|
SSH_KEY=$(node bin config get --plain DEFAULT_SSH_KEY_PATH)
|
|
7
8
|
|
|
8
9
|
chmod 600 "$SSH_KEY"
|
|
9
10
|
|
|
10
|
-
ssh -i "$SSH_KEY" -o BatchMode=yes "${REMOTE_USER}@${REMOTE_HOST}" sh <<EOF
|
|
11
|
+
ssh -i "$SSH_KEY" -o BatchMode=yes "${REMOTE_USER}@${REMOTE_HOST}" -p ${REMOTE_PORT} sh <<EOF
|
|
11
12
|
cd /home/dd/engine
|
|
12
|
-
node bin deploy dd production --status
|
|
13
|
-
kubectl get pods -A
|
|
13
|
+
sudo -n -- /bin/bash -lc "node bin deploy dd production --status"
|
|
14
|
+
sudo -n -- /bin/bash -lc "kubectl get pods -A"
|
|
14
15
|
EOF
|
package/src/cli/cluster.js
CHANGED
|
@@ -558,7 +558,7 @@ net.ipv4.ip_forward = 1' | sudo tee ${iptableConfPath}`,
|
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
if (kubeconfigPath) {
|
|
561
|
-
shellExec(`sudo -E cp -i ${kubeconfigPath} ~/.kube/config`);
|
|
561
|
+
shellExec(`sudo -E cp -i -f ${kubeconfigPath} ~/.kube/config`);
|
|
562
562
|
shellExec(`sudo -E chown $(id -u):$(id -g) ~/.kube/config`);
|
|
563
563
|
} else if (clusterType === 'kind') {
|
|
564
564
|
// For Kind, the kubeconfig is usually merged automatically or can be explicitly exported
|