termux-connecting 1.1.12 → 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.12"
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,91 +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
 
46
- # Pastikan coreutils (timeout) tersedia
56
+ # ─── 1. coreutils ───
47
57
  if ! command -v timeout >/dev/null; then
48
- echo " Install coreutils untuk timeout..."
49
- pkg install -y coreutils
58
+ echo " Dibutuhkan: coreutils (untuk timeout)"
59
+ if confirm "Install coreutils" "y"; then
60
+ pkg install -y coreutils
61
+ fi
50
62
  fi
51
63
 
64
+ # ─── 2. Update & Upgrade ───
52
65
  title "1. Update & Upgrade Paket"
53
- echo "Menjalankan pkg update && pkg upgrade..."
54
- if timeout 300 pkg update -y && timeout 300 pkg upgrade -y; then
55
- info "Update & upgrade berhasil"
56
- else
57
- warn "Gagal update/upgrade. Mungkin repo tidak stabil."
58
- echo ""
59
- echo " Untuk mengganti ke repo stable, jalankan:"
60
- echo " termux-change-repo"
61
- echo ""
62
- echo " Pilih mirror yang stabil:"
63
- echo " - SourceForge (SF) — paling stabil"
64
- echo " - Grimler — recommended"
65
- echo " - Albatross — alternatif"
66
- echo ""
67
- echo -n " Ingin ganti repo sekarang? [y/N]: "
68
- read -r change_repo
69
- if [[ "$change_repo" =~ ^[Yy]$ ]]; then
70
- 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."
72
+ echo ""
73
+ echo " Untuk mengganti ke repo stable, jalankan:"
74
+ echo " termux-change-repo"
71
75
  echo ""
72
- echo " Ulangi update setelah selesai:"
73
- echo " termux-connecting"
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
74
86
  fi
87
+ else
88
+ warn "Lewati update/upgrade"
75
89
  fi
76
90
 
91
+ # ─── 3. Git & Node.js ───
77
92
  title "2. Cek Git & Node.js"
78
93
  for cmd in git node; do
79
- if command -v "$cmd"; then
94
+ if command -v "$cmd" >/dev/null; then
80
95
  info "$cmd sudah terinstall ($($cmd --version || echo '?'))"
81
96
  else
82
- warn "$cmd belum terinstall."
83
- echo -n " Install $cmd sekarang? [Y/n]: "
84
- read -r install_it
85
- if [[ -z "$install_it" || "$install_it" =~ ^[Yy]$ ]]; then
86
- if [ "$cmd" = "node" ]; then
87
- pkg install -y nodejs-lts && info "$cmd berhasil diinstall" || error "Gagal install $cmd"
88
- else
89
- pkg install -y "$cmd" && info "$cmd berhasil diinstall" || error "Gagal install $cmd"
90
- 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"
91
102
  else
92
103
  warn "Lewati install $cmd"
93
104
  fi
94
105
  fi
95
106
  done
96
107
 
108
+ # ─── 4. Password ───
97
109
  title "3. Cek Password (passwd)"
98
- 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
99
111
  info "Password sudah diatur"
100
112
  else
101
- warn "Belum ada password. Setting password diperlukan untuk SSH."
102
- echo ""
103
- echo " Masukkan password baru:"
104
- if passwd; then
105
- 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
106
122
  else
107
- error "Gagal menyimpan password"
123
+ warn "Lewati set password. SSH tidak akan bisa tanpa password."
108
124
  fi
109
125
  fi
110
126
 
127
+ # ─── 5. Informasi Koneksi ───
111
128
  title "4. Informasi Koneksi"
112
129
  USERNAME=$(whoami)
113
130
 
114
- # Deteksi IP — coba beberapa metode
115
131
  IP=""
116
- if command -v ip; then
132
+ if command -v ip >/dev/null; then
117
133
  IP=$(ip -4 addr show | awk '/inet /{print $2}' | cut -d/ -f1 | grep -v 127.0.0.1 | head -1)
118
134
  fi
119
- if [ -z "$IP" ] && command -v ifconfig; then
135
+ if [ -z "$IP" ] && command -v ifconfig >/dev/null; then
120
136
  IP=$(ifconfig | awk '/inet /{print $2}' | grep -v 127.0.0.1 | head -1)
121
137
  fi
122
- if [ -z "$IP" ] && command -v hostname; then
138
+ if [ -z "$IP" ] && command -v hostname >/dev/null; then
123
139
  IP=$(hostname -I 2>/dev/null | awk '{print $1}')
124
140
  fi
125
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.12",
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",