setup-kapelu 3.2.10 β 3.2.11
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/cli.js +39 -63
- package/install.sh +112 -104
- package/package.json +5 -2
package/cli.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { execSync } = require("child_process");
|
|
4
|
+
const { existsSync } = require("fs");
|
|
4
5
|
const pkg = require("./package.json");
|
|
5
|
-
const { clear } = require("console");
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function run(cmd, options = {}) {
|
|
8
|
+
execSync(cmd, { stdio: "inherit", shell: "/bin/bash", ...options });
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function commandExists(cmd) {
|
|
8
12
|
try {
|
|
9
13
|
execSync(`command -v ${cmd}`, { stdio: "ignore" });
|
|
10
14
|
return true;
|
|
@@ -13,78 +17,50 @@ function exists(cmd) {
|
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} catch {
|
|
30
|
-
return null;
|
|
20
|
+
function ensureNode() {
|
|
21
|
+
if (!commandExists("node") || !commandExists("npm")) {
|
|
22
|
+
console.log("π¦ Node.js y npm no detectados. Instalando...");
|
|
23
|
+
run(
|
|
24
|
+
"curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash",
|
|
25
|
+
);
|
|
26
|
+
run(
|
|
27
|
+
'export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"',
|
|
28
|
+
);
|
|
29
|
+
run("nvm install --lts && nvm use --lts");
|
|
30
|
+
run("npm install -g pnpm yarn");
|
|
31
|
+
} else {
|
|
32
|
+
console.log("β Node.js y npm OK");
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
function
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
console.log(
|
|
42
|
-
|
|
36
|
+
function updateKapelu() {
|
|
37
|
+
const latest = execSync(`npm view ${pkg.name} version`, {
|
|
38
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
39
|
+
})
|
|
40
|
+
.toString()
|
|
41
|
+
.trim();
|
|
42
|
+
if (pkg.version !== latest) {
|
|
43
|
+
console.log(`β¬ Nueva versiΓ³n disponible: ${latest}. Actualizando...`);
|
|
44
|
+
run(`npm install -g ${pkg.name}`);
|
|
43
45
|
process.exit(0);
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
function autoUpdateGitHub() {
|
|
48
|
-
// Si el script existe, hacer pull del repo para tener versiΓ³n mΓ‘s reciente
|
|
49
|
-
try {
|
|
50
|
-
execSync(
|
|
51
|
-
`if [ -d "/tmp/script-setup" ]; then cd /tmp/script-setup && git pull --rebase; fi`,
|
|
52
|
-
{ stdio: "inherit", shell: "/bin/bash" },
|
|
53
|
-
);
|
|
54
|
-
} catch {}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
49
|
try {
|
|
58
|
-
console.log("π Verificando Node
|
|
59
|
-
|
|
60
|
-
console.log("β Node.js y npm OK\n");
|
|
61
|
-
|
|
62
|
-
console.log("π Verificando actualizaciones en npm...");
|
|
63
|
-
updateIfNeeded();
|
|
50
|
+
console.log("π Verificando Node/npm...");
|
|
51
|
+
ensureNode();
|
|
64
52
|
|
|
65
|
-
console.log("π
|
|
66
|
-
|
|
53
|
+
console.log("π Verificando actualizaciones...");
|
|
54
|
+
updateKapelu();
|
|
67
55
|
|
|
68
|
-
console.log("π Ejecutando
|
|
69
|
-
|
|
56
|
+
console.log("π Ejecutando instalador completo...");
|
|
57
|
+
run(`bash ${__dirname}/install.sh`);
|
|
70
58
|
} catch (err) {
|
|
71
59
|
console.clear();
|
|
72
|
-
|
|
73
|
-
console.error("
|
|
74
|
-
|
|
75
|
-
if (err.
|
|
76
|
-
console.error("CΓ³digo de salida:", err.status);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (err.cmd) {
|
|
80
|
-
console.error("Comando:", err.cmd);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (err.stderr) {
|
|
84
|
-
console.error(err.stderr.toString());
|
|
85
|
-
}
|
|
86
|
-
|
|
60
|
+
console.error("\nβ Error ejecutando setup-kapelu\n");
|
|
61
|
+
if (err.status) console.error("CΓ³digo de salida:", err.status);
|
|
62
|
+
if (err.cmd) console.error("Comando:", err.cmd);
|
|
63
|
+
if (err.stderr) console.error(err.stderr.toString());
|
|
87
64
|
console.error(err.message);
|
|
88
|
-
|
|
89
65
|
process.exit(1);
|
|
90
|
-
}
|
|
66
|
+
}
|
package/install.sh
CHANGED
|
@@ -1,112 +1,107 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
3
|
-
# β
|
|
3
|
+
# β Install - Script Post-Install Todo en Uno β
|
|
4
|
+
# β VersiΓ³n: 3.2.9 β
|
|
4
5
|
# β Autor: Daniel Calderon - Kapelu β
|
|
5
|
-
# β Fecha:
|
|
6
|
+
# β Fecha: 04/03/2026 β
|
|
7
|
+
# β WebSite: https://danielcalderon.vercel.app/ β
|
|
8
|
+
# β Github: https://github.com/Kapelu β
|
|
6
9
|
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
7
10
|
|
|
8
11
|
set -Eeuo pipefail
|
|
9
12
|
IFS=$'\n\t'
|
|
10
13
|
|
|
11
|
-
GREEN='\e[32m'
|
|
12
|
-
RESET='\e[0m'
|
|
13
|
-
|
|
14
14
|
USER_NAME=$(whoami)
|
|
15
|
-
HOME_DIR
|
|
15
|
+
HOME_DIR=$HOME
|
|
16
16
|
DESKTOP_DIR=$(xdg-user-dir DESKTOP)
|
|
17
17
|
TMP_DIR="/tmp/kape-setup-$RANDOM"
|
|
18
18
|
REPO="https://github.com/Kapelu/kape-setup.git"
|
|
19
|
+
LOG="$HOME/setup-kapelu.log"
|
|
20
|
+
green='\e[32m'
|
|
21
|
+
reset='\e[0m'
|
|
19
22
|
|
|
20
|
-
log() {
|
|
23
|
+
log() {
|
|
24
|
+
echo -e "${green}β
$1${reset}"
|
|
25
|
+
echo "$1" >> "$LOG"
|
|
26
|
+
}
|
|
21
27
|
|
|
22
|
-
#
|
|
28
|
+
# Detectar distro soportada
|
|
23
29
|
detect_distro() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
if [ ! -f /etc/os-release ]; then
|
|
31
|
+
log "Sistema no soportado"
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
source /etc/os-release
|
|
36
|
+
case "$ID" in
|
|
37
|
+
ubuntu|debian|linuxmint|pop)
|
|
38
|
+
log "DistribuciΓ³n detectada: $ID"
|
|
39
|
+
;;
|
|
40
|
+
*)
|
|
41
|
+
log "DistribuciΓ³n no soportada: $ID"
|
|
42
|
+
exit 1
|
|
43
|
+
;;
|
|
44
|
+
esac
|
|
39
45
|
}
|
|
40
46
|
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
# Instalar git si no existe
|
|
48
|
+
check_git() {
|
|
49
|
+
if ! command -v git >/dev/null; then
|
|
50
|
+
log "Instalando git"
|
|
51
|
+
sudo apt update
|
|
52
|
+
sudo apt install -y git
|
|
53
|
+
fi
|
|
47
54
|
}
|
|
48
55
|
|
|
49
|
-
#
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
57
|
-
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
|
|
58
|
-
|
|
59
|
-
log "Instalando Node LTS..."
|
|
60
|
-
nvm install --lts
|
|
61
|
-
nvm use --lts
|
|
62
|
-
nvm alias default 'lts/*'
|
|
63
|
-
|
|
64
|
-
log "Node $(node -v) y npm $(npm -v) listos"
|
|
56
|
+
# Dar permisos a scripts con shebang
|
|
57
|
+
permits() {
|
|
58
|
+
while IFS= read -r -d '' file; do
|
|
59
|
+
if head -n1 "$file" | grep -q "^#!"; then
|
|
60
|
+
chmod +x "$file"
|
|
61
|
+
fi
|
|
62
|
+
done < <(find . -type f -print0)
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
log "setup-kapelu instalado correctamente"
|
|
73
|
-
else
|
|
74
|
-
echo "β Error instalando setup-kapelu"
|
|
75
|
-
exit 1
|
|
76
|
-
fi
|
|
65
|
+
backup_bashrc() {
|
|
66
|
+
if [ -f "$HOME_DIR/.bashrc" ]; then
|
|
67
|
+
cp "$HOME_DIR/.bashrc" "$HOME_DIR/.bashrc.backup.$(date +%s)"
|
|
68
|
+
log "Backup de .bashrc creado"
|
|
69
|
+
fi
|
|
77
70
|
}
|
|
78
71
|
|
|
79
|
-
#
|
|
72
|
+
# Clonar repo temporal
|
|
80
73
|
clone_repo() {
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
log "Clonando repositorio"
|
|
75
|
+
git clone -b main "$REPO" "$TMP_DIR"
|
|
83
76
|
}
|
|
84
77
|
|
|
85
|
-
#
|
|
78
|
+
# Copiar scripts al home
|
|
86
79
|
copy_scripts() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
80
|
+
mkdir -p "$HOME_DIR/script"
|
|
81
|
+
cp -r "$TMP_DIR/script/." "$HOME_DIR/script/"
|
|
82
|
+
find "$HOME_DIR/script" -type f -name "*.sh" -exec chmod +x {} \;
|
|
90
83
|
}
|
|
91
84
|
|
|
92
|
-
#
|
|
85
|
+
# Copiar configs
|
|
93
86
|
copy_config() {
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
cp "$TMP_DIR/config/.bashrc" "$HOME_DIR/.bashrc"
|
|
88
|
+
cp "$TMP_DIR/config/protect-main.json" "$HOME_DIR/"
|
|
96
89
|
}
|
|
97
90
|
|
|
98
|
-
#
|
|
91
|
+
# Crear accesos directos en el escritorio
|
|
99
92
|
create_desktop() {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
93
|
+
mkdir -p "$DESKTOP_DIR"
|
|
94
|
+
|
|
95
|
+
DATA=(
|
|
96
|
+
"log|Logout|Cierra sesiΓ³n en 10 segundos|system-log-out"
|
|
97
|
+
"shd|Apagar|Apaga la PC en 10 segundos|system-shutdown"
|
|
98
|
+
"sus|Suspender|Suspende la PC en 10 segundos|system-suspend"
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
for row in "${DATA[@]}"; do
|
|
102
|
+
IFS="|" read -r id name comment icon <<< "$row"
|
|
103
|
+
file="$DESKTOP_DIR/btn_${id}.desktop"
|
|
104
|
+
cat <<EOF > "$file"
|
|
110
105
|
[Desktop Entry]
|
|
111
106
|
Name=$name
|
|
112
107
|
Comment=$comment
|
|
@@ -116,41 +111,54 @@ Terminal=false
|
|
|
116
111
|
Type=Application
|
|
117
112
|
Categories=Utility;
|
|
118
113
|
EOF
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
chmod +x "$file"
|
|
115
|
+
gio set "$file" metadata::trusted true
|
|
116
|
+
done
|
|
117
|
+
|
|
118
|
+
killall -q nautilus 2>/dev/null
|
|
123
119
|
}
|
|
124
120
|
|
|
125
|
-
|
|
121
|
+
system_update() { sudo apt update -y; sudo apt upgrade -y; sudo apt full-upgrade -y; }
|
|
122
|
+
system_cleanup() { sudo apt autoremove -y; sudo apt clean; }
|
|
123
|
+
|
|
124
|
+
# Ejecutar setup.sh final
|
|
126
125
|
run_setup() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
printf "${green}π¦ ΒΏDesea ejecutar setup.sh? (s/n): ${reset}"
|
|
127
|
+
read RESP
|
|
128
|
+
|
|
129
|
+
if [ "$RESP" = "s" ]; then
|
|
130
|
+
FILE="$HOME_DIR/script/setup.sh"
|
|
131
|
+
|
|
132
|
+
if [ ! -f "$FILE" ]; then
|
|
133
|
+
echo "β Error: setup.sh no encontrado en $HOME_DIR/script/"
|
|
134
|
+
return 1
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
if [ ! -x "$FILE" ]; then
|
|
138
|
+
chmod +x "$FILE"
|
|
139
|
+
fi
|
|
140
|
+
|
|
141
|
+
"$FILE"
|
|
142
|
+
else
|
|
143
|
+
system_update
|
|
144
|
+
system_cleanup
|
|
145
|
+
fi
|
|
134
146
|
}
|
|
135
147
|
|
|
136
|
-
|
|
137
|
-
cleanup() {
|
|
138
|
-
rm -rf "$TMP_DIR"
|
|
139
|
-
}
|
|
148
|
+
cleanup() { rm -rf "$TMP_DIR"; }
|
|
140
149
|
|
|
141
|
-
# ββββββββββββββ Main ββββββββββββββ
|
|
142
150
|
main() {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
151
|
+
log "Iniciando Secuencia Post-Install setup-kapelu"
|
|
152
|
+
|
|
153
|
+
detect_distro
|
|
154
|
+
check_git
|
|
155
|
+
clone_repo
|
|
156
|
+
copy_scripts
|
|
157
|
+
backup_bashrc
|
|
158
|
+
copy_config
|
|
159
|
+
create_desktop
|
|
160
|
+
run_setup
|
|
161
|
+
cleanup
|
|
154
162
|
}
|
|
155
163
|
|
|
156
164
|
main
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "setup-kapelu",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.11",
|
|
4
4
|
"description": "Script post-install de Ubuntu",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"bin": {
|
|
@@ -33,5 +33,8 @@
|
|
|
33
33
|
"bugs": {
|
|
34
34
|
"url": "https://github.com/Kapelu/kape-setup/issues"
|
|
35
35
|
},
|
|
36
|
-
"homepage": "https://github.com/Kapelu/kape-setup#readme"
|
|
36
|
+
"homepage": "https://github.com/Kapelu/kape-setup#readme",
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18"
|
|
39
|
+
}
|
|
37
40
|
}
|