termux-connecting 1.1.11 → 1.1.13

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
- VERSION="1.1.11"
4
+ VERSION="1.1.13"
5
5
  CONFIG_DIR="$HOME/.config/termux-connecting"
6
6
  CONFIG_FILE="$CONFIG_DIR/config"
7
7
  SSH_PORT=8022
@@ -1,18 +1,28 @@
1
1
  #!/data/data/com.termux/files/usr/bin/bash
2
-
3
2
  set -e
4
3
 
5
- GREEN='\033[0;32m'
6
- YELLOW='\033[1;33m'
7
- RED='\033[0;31m'
8
- CYAN='\033[0;36m'
9
- NC='\033[0m'
10
-
4
+ GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; CYAN='\033[0;36m'; NC='\033[0m'
11
5
  info() { echo -e "${GREEN}[✓]${NC} $1"; }
12
6
  warn() { echo -e "${YELLOW}[!]${NC} $1"; }
13
7
  error() { echo -e "${RED}[✗]${NC} $1"; }
14
8
  title() { echo -e "\n${CYAN}━━━ $1 ━━━${NC}\n"; }
15
9
 
10
+ AUTO=false
11
+ for arg in "$@"; do
12
+ [ "$arg" = "-y" ] && AUTO=true
13
+ done
14
+
15
+ confirm() {
16
+ local msg="$1" default="$2"
17
+ $AUTO && return 0
18
+ local dprompt="y/N"
19
+ [ "$default" = "y" ] && dprompt="Y/n"
20
+ echo -n " ${msg}? [${dprompt}]: "
21
+ read -r ans
22
+ local ans="${ans:-$default}"
23
+ [[ "$ans" =~ ^[Yy]$ ]] && return 0 || return 1
24
+ }
25
+
16
26
  WELCOME_FILE="$HOME/.config/termux-connecting/.welcomed"
17
27
  if [ ! -f "$WELCOME_FILE" ]; then
18
28
  echo ""
@@ -35,85 +45,97 @@ if [ ! -f "$WELCOME_FILE" ]; then
35
45
  echo " termux-connect-pc help Bantuan"
36
46
  echo " termux-connect-pc version Versi"
37
47
  echo ""
48
+ echo -e "${YELLOW}Gunakan -y untuk skip semua konfirmasi: termux-connecting -y${NC}"
49
+ echo ""
38
50
  mkdir -p "$HOME/.config/termux-connecting"
39
51
  touch "$WELCOME_FILE"
40
52
  fi
41
53
 
42
54
  title "TERMUX CONNECTING — Setup"
43
- echo "Memeriksa dan mengkonfigurasi Termux..."
44
- echo "----------------------------------------"
45
55
 
56
+ # ─── 1. coreutils ───
57
+ if ! command -v timeout >/dev/null; then
58
+ echo " Dibutuhkan: coreutils (untuk timeout)"
59
+ if confirm "Install coreutils" "y"; then
60
+ pkg install -y coreutils
61
+ fi
62
+ fi
63
+
64
+ # ─── 2. Update & Upgrade ───
46
65
  title "1. Update & Upgrade Paket"
47
- echo "Menjalankan pkg update && pkg upgrade..."
48
- if timeout 300 pkg update -y && timeout 300 pkg upgrade -y; then
49
- info "Update & upgrade berhasil"
50
- else
51
- warn "Gagal update/upgrade. Mungkin repo tidak stabil."
52
- echo ""
53
- echo " Untuk mengganti ke repo stable, jalankan:"
54
- echo " termux-change-repo"
55
- echo ""
56
- echo " Pilih mirror yang stabil:"
57
- echo " - SourceForge (SF) — paling stabil"
58
- echo " - Grimler — recommended"
59
- echo " - Albatross — alternatif"
60
- echo ""
61
- echo -n " Ingin ganti repo sekarang? [y/N]: "
62
- read -r change_repo
63
- if [[ "$change_repo" =~ ^[Yy]$ ]]; then
64
- termux-change-repo
66
+ if confirm "Jalankan pkg update && pkg upgrade" "y"; then
67
+ echo " Menjalankan pkg update && pkg upgrade..."
68
+ if timeout 300 pkg update -y && timeout 300 pkg upgrade -y; then
69
+ info "Update & upgrade berhasil"
70
+ else
71
+ warn "Gagal update/upgrade. Mungkin repo tidak stabil."
65
72
  echo ""
66
- echo " Ulangi update setelah selesai:"
67
- echo " termux-connecting"
73
+ echo " Untuk mengganti ke repo stable, jalankan:"
74
+ echo " termux-change-repo"
75
+ echo ""
76
+ echo " Pilih mirror yang stabil:"
77
+ echo " - SourceForge (SF) — paling stabil"
78
+ echo " - Grimler — recommended"
79
+ echo " - Albatross — alternatif"
80
+ echo ""
81
+ if confirm "Ganti repo sekarang" "n"; then
82
+ termux-change-repo
83
+ echo ""
84
+ echo " Ulangi: termux-connecting"
85
+ fi
68
86
  fi
87
+ else
88
+ warn "Lewati update/upgrade"
69
89
  fi
70
90
 
91
+ # ─── 3. Git & Node.js ───
71
92
  title "2. Cek Git & Node.js"
72
93
  for cmd in git node; do
73
- if command -v "$cmd"; then
94
+ if command -v "$cmd" >/dev/null; then
74
95
  info "$cmd sudah terinstall ($($cmd --version || echo '?'))"
75
96
  else
76
- warn "$cmd belum terinstall."
77
- echo -n " Install $cmd sekarang? [Y/n]: "
78
- read -r install_it
79
- if [[ -z "$install_it" || "$install_it" =~ ^[Yy]$ ]]; then
80
- if [ "$cmd" = "node" ]; then
81
- pkg install -y nodejs-lts && info "$cmd berhasil diinstall" || error "Gagal install $cmd"
82
- else
83
- pkg install -y "$cmd" && info "$cmd berhasil diinstall" || error "Gagal install $cmd"
84
- fi
97
+ echo " $cmd belum terinstall."
98
+ if confirm "Install $cmd" "y"; then
99
+ pkg="$cmd"
100
+ [ "$cmd" = "node" ] && pkg="nodejs-lts"
101
+ pkg install -y "$pkg" && info "$cmd berhasil diinstall" || error "Gagal install $cmd"
85
102
  else
86
103
  warn "Lewati install $cmd"
87
104
  fi
88
105
  fi
89
106
  done
90
107
 
108
+ # ─── 4. Password ───
91
109
  title "3. Cek Password (passwd)"
92
- if [ -f "$HOME/.termux_authinfo" ] || passwd -S | grep -q "P"; then
110
+ if [ -f "$HOME/.termux_authinfo" ] || passwd -S 2>/dev/null | grep -q "P"; then
93
111
  info "Password sudah diatur"
94
112
  else
95
- warn "Belum ada password. Setting password diperlukan untuk SSH."
96
- echo ""
97
- echo " Masukkan password baru:"
98
- if passwd; then
99
- info "Password berhasil disimpan"
113
+ echo " Belum ada password. Setting password diperlukan untuk SSH."
114
+ if confirm "Set password sekarang" "y"; then
115
+ echo ""
116
+ echo " Masukkan password baru:"
117
+ if passwd; then
118
+ info "Password berhasil disimpan"
119
+ else
120
+ error "Gagal menyimpan password"
121
+ fi
100
122
  else
101
- error "Gagal menyimpan password"
123
+ warn "Lewati set password. SSH tidak akan bisa tanpa password."
102
124
  fi
103
125
  fi
104
126
 
127
+ # ─── 5. Informasi Koneksi ───
105
128
  title "4. Informasi Koneksi"
106
129
  USERNAME=$(whoami)
107
130
 
108
- # Deteksi IP — coba beberapa metode
109
131
  IP=""
110
- if command -v ip; then
132
+ if command -v ip >/dev/null; then
111
133
  IP=$(ip -4 addr show | awk '/inet /{print $2}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -1)
112
134
  fi
113
- if [ -z "$IP" ] && command -v ifconfig; then
135
+ if [ -z "$IP" ] && command -v ifconfig >/dev/null; then
114
136
  IP=$(ifconfig | awk '/inet /{print $2}' | grep -v 127.0.0.1 | head -1)
115
137
  fi
116
- if [ -z "$IP" ] && command -v hostname; then
138
+ if [ -z "$IP" ] && command -v hostname >/dev/null; then
117
139
  IP=$(hostname -I 2>/dev/null | awk '{print $1}')
118
140
  fi
119
141
  if [ -z "$IP" ] && [ -d /data/data/com.termux ]; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "termux-connecting",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "description": "CLI setup Termux + koneksi SSH dari PC/Mac dengan Telegram alert",
5
5
  "bin": {
6
6
  "termux-connecting": "bin/termux-connecting",