mirror of
https://github.com/bugfloyd/dnstt-deploy.git
synced 2026-07-18 08:06:09 +02:00
feat: add update command and main menu
This commit is contained in:
+99
-21
@@ -33,6 +33,8 @@
|
||||
## ویژگیها
|
||||
|
||||
- **پشتیبانی از چندین توزیع**: Fedora، Rocky Linux، CentOS، Debian، Ubuntu
|
||||
- **منوی مدیریت تعاملی**: رابط کاربری آسان برای همه عملیات
|
||||
- **قابلیت خودبروزرسانی**: مکانیزم بروزرسانی داخلی برای اسکریپت
|
||||
- **تشخیص خودکار**: تشخیص OS، معماری و پورت SSH
|
||||
- **امنیت تقویت شده**: اجرای سرویس غیر root با ویژگیهای امنیتی systemd
|
||||
- **پیکربندی هوشمند**: تنظیمات پایدار و استفاده مجدد خودکار از کلیدها
|
||||
@@ -51,20 +53,38 @@
|
||||
|
||||
### نصب
|
||||
|
||||
1. **دانلود اسکریپت:**
|
||||
```bash
|
||||
wget https://raw.githubusercontent.com/bugfloyd/dnstt-deploy/main/dnstt-deploy.sh
|
||||
```
|
||||
**نصب با یک دستور:**
|
||||
```bash
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/bugfloyd/dnstt-deploy/main/dnstt-deploy.sh)
|
||||
```
|
||||
|
||||
2. **اجرای راهاندازی:**
|
||||
```bash
|
||||
sudo ./dnstt-deploy.sh
|
||||
```
|
||||
این دستور انجام خواهد داد:
|
||||
1. دانلود و نصب اسکریپت در `/usr/local/bin/dnstt-deploy`
|
||||
2. شروع فرآیند راهاندازی تعاملی
|
||||
3. پیکربندی خودکار سرور dnstt شما
|
||||
|
||||
3. **دنبال کردن راهنمای تعاملی:**
|
||||
- زیردامنه nameserver خود را وارد کنید (مثل `t.example.com`)
|
||||
- مقدار MTU را تنظیم کنید (پیشفرض: 1232)
|
||||
- حالت تونل را انتخاب کنید (SSH یا SOCKS)
|
||||
### استفاده پس از نصب
|
||||
|
||||
پس از نصب، میتوانید سرور dnstt خود را با استفاده از دستور نصب شده مدیریت کنید:
|
||||
|
||||
```bash
|
||||
dnstt-deploy
|
||||
```
|
||||
|
||||
این دستور منوی تعاملی با گزینههای زیر را نشان میدهد:
|
||||
|
||||
1. **نصب/پیکربندی مجدد سرور dnstt** - راهاندازی یا تغییر پیکربندی
|
||||
2. **بروزرسانی اسکریپت dnstt-deploy** - بررسی و نصب بروزرسانیهای اسکریپت
|
||||
3. **بررسی وضعیت سرویس** - مشاهده وضعیت فعلی سرویس
|
||||
4. **مشاهده لاگهای سرویس** - نظارت بر لاگهای real-time (Ctrl+C برای خروج)
|
||||
5. **خروج** - خروج از منو
|
||||
|
||||
### فرآیند راهاندازی
|
||||
|
||||
در طول راهاندازی (گزینه 1)، از شما خواسته میشود:
|
||||
- **زیردامنه nameserver** (مثل `t.example.com`)
|
||||
- **مقدار MTU** (پیشفرض: 1232)
|
||||
- **حالت تونل** (SSH یا SOCKS)
|
||||
|
||||
## پیکربندی
|
||||
|
||||
@@ -91,7 +111,12 @@
|
||||
- شبکههای موبایل محدود: 512
|
||||
|
||||
### تغییر تنظیمات
|
||||
برای تغییر MTU یا سایر تنظیمات، به سادگی اسکریپت را مجدداً اجرا کنید و مقادیر جدید را وارد کنید. اسکریپت به طور خودکار پیکربندی را بروزرسانی کرده و سرویسها را مجدداً راهاندازی میکند.
|
||||
برای تغییر MTU یا سایر تنظیمات:
|
||||
1. `dnstt-deploy` را اجرا کنید
|
||||
2. گزینه 1 (نصب/پیکربندی مجدد سرور dnstt) را انتخاب کنید
|
||||
3. مقادیر جدید را هنگام درخواست وارد کنید
|
||||
|
||||
اسکریپت به طور خودکار پیکربندی را بروزرسانی کرده و سرویسها را مجدداً راهاندازی میکند.
|
||||
|
||||
## استفاده از کلاینت
|
||||
|
||||
@@ -152,18 +177,35 @@ scutil --dns | grep nameserver
|
||||
|
||||
## مدیریت
|
||||
|
||||
### منوی مدیریت
|
||||
|
||||
آسانترین راه برای مدیریت سرور dnstt شما از طریق منوی تعاملی است:
|
||||
|
||||
```bash
|
||||
dnstt-deploy
|
||||
```
|
||||
|
||||
این دستور دسترسی سریع به موارد زیر فراهم میکند:
|
||||
- پیکربندی مجدد سرور
|
||||
- بروزرسانی اسکریپت
|
||||
- نظارت بر وضعیت سرویس
|
||||
- مشاهده لاگهای real-time
|
||||
|
||||
### محل فایلها
|
||||
|
||||
```
|
||||
/usr/local/bin/dnstt-server # باینری اصلی
|
||||
/etc/dnstt/ # دایرکتوری پیکربندی
|
||||
├── dnstt-server.conf # پیکربندی اصلی
|
||||
├── {domain}_server.key # کلید خصوصی (برای هر دامنه)
|
||||
└── {domain}_server.pub # کلید عمومی (برای هر دامنه)
|
||||
/usr/local/bin/dnstt-deploy # اسکریپت مدیریت
|
||||
/usr/local/bin/dnstt-server # باینری اصلی
|
||||
/etc/dnstt/ # دایرکتوری پیکربندی
|
||||
├── dnstt-server.conf # پیکربندی اصلی
|
||||
├── {domain}_server.key # کلید خصوصی (برای هر دامنه)
|
||||
└── {domain}_server.pub # کلید عمومی (برای هر دامنه)
|
||||
/etc/systemd/system/dnstt-server.service # سرویس systemd
|
||||
```
|
||||
|
||||
### دستورات سرویس
|
||||
### دستورات سرویس دستی
|
||||
|
||||
اگر مدیریت خط فرمان را ترجیح میدهید:
|
||||
|
||||
**سرویس dnstt-server**:
|
||||
```bash
|
||||
@@ -183,8 +225,31 @@ sudo systemctl restart danted # راهاندازی مجدد سروی
|
||||
sudo journalctl -u danted -f # مشاهده لاگها
|
||||
```
|
||||
|
||||
### بروزرسانی اسکریپت
|
||||
|
||||
اسکریپت میتواند خود را به دو روش بروزرسانی کند:
|
||||
|
||||
**روش 1: استفاده از منو (توصیه میشود)**
|
||||
```bash
|
||||
dnstt-deploy
|
||||
# گزینه 2 را انتخاب کنید: بروزرسانی اسکریپت dnstt-deploy
|
||||
```
|
||||
|
||||
**روش 2: اجرای مجدد دستور curl**
|
||||
```bash
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/bugfloyd/dnstt-deploy/main/dnstt-deploy.sh)
|
||||
# اسکریپت به طور خودکار بروزرسانیها را تشخیص داده و نصب خواهد کرد
|
||||
```
|
||||
|
||||
## عیبیابی
|
||||
|
||||
### استفاده از ابزارهای داخلی
|
||||
|
||||
منوی مدیریت دسترسی سریع به ابزارهای عیبیابی فراهم میکند:
|
||||
|
||||
1. **بررسی وضعیت سرویس** (گزینه منو 3): نشان میدهد که آیا سرویسها به درستی اجرا میشوند
|
||||
2. **مشاهده لاگهای سرویس** (گزینه منو 4): نظارت real-time بر لاگهای سرویس
|
||||
|
||||
### خطاهای اندازه MTU
|
||||
|
||||
اگر خطاهایی مثل این میبینید:
|
||||
@@ -192,12 +257,19 @@ sudo journalctl -u danted -f # مشاهده لاگها
|
||||
FORMERR: requester payload size 512 is too small (minimum 1232)
|
||||
```
|
||||
|
||||
MTU را به عدد ذکر شده کاهش دهید با اجرای مجدد اسکریپت و وارد کردن مقدار MTU پیشنهادی. مبادلات عملکرد را هنگام استفاده از مقادیر MTU بسیار پایین در نظر بگیرید.
|
||||
MTU را به عدد ذکر شده کاهش دهید:
|
||||
1. `dnstt-deploy` را اجرا کنید
|
||||
2. گزینه 1 (نصب/پیکربندی مجدد سرور dnstt) را انتخاب کنید
|
||||
3. مقدار MTU پیشنهادی را هنگام درخواست وارد کنید
|
||||
|
||||
مبادلات عملکرد را هنگام استفاده از مقادیر MTU بسیار پایین در نظر بگیرید.
|
||||
|
||||
### مشکلات رایج
|
||||
|
||||
**سرویس شروع نمیشود**:
|
||||
```bash
|
||||
dnstt-deploy # از گزینه منو 3 برای بررسی وضعیت استفاده کنید
|
||||
# یا به صورت دستی:
|
||||
sudo systemctl status dnstt-server # بررسی وضعیت سرویس
|
||||
sudo journalctl -u dnstt-server -n 50 # بررسی لاگها برای خطاها
|
||||
ls -la /usr/local/bin/dnstt-server # تأیید مجوزهای باینری
|
||||
@@ -225,7 +297,11 @@ sudo ss -tulnp | grep 1080 # بررسی پورت پروکسی SOCKS (در صو
|
||||
|
||||
### پشتیبانی از چندین دامنه
|
||||
|
||||
اسکریپت از چندین دامنه با ایجاد جفت کلیدهای جداگانه برای هر دامنه پشتیبانی میکند. با این حال، تنها یک پیکربندی دامنه میتواند در یک زمان فعال باشد زیرا همه پیکربندیها از پورت 53 برای ترافیک DNS استفاده میکنند. برای تغییر بین دامنهها، به سادگی اسکریپت را با زیردامنه متفاوت مجدداً اجرا کنید.
|
||||
اسکریپت از چندین دامنه با ایجاد جفت کلیدهای جداگانه برای هر دامنه پشتیبانی میکند. با این حال، تنها یک پیکربندی دامنه میتواند در یک زمان فعال باشد زیرا همه پیکربندیها از پورت 53 برای ترافیک DNS استفاده میکنند. برای تغییر بین دامنهها:
|
||||
|
||||
1. `dnstt-deploy` را اجرا کنید
|
||||
2. گزینه 1 (نصب/پیکربندی مجدد سرور dnstt) را انتخاب کنید
|
||||
3. زیردامنه جدید را هنگام درخواست وارد کنید
|
||||
|
||||
### پشتیبانی از DoH و DoT
|
||||
|
||||
@@ -233,6 +309,8 @@ sudo ss -tulnp | grep 1080 # بررسی پورت پروکسی SOCKS (در صو
|
||||
|
||||
### نظارت بر عملکرد
|
||||
|
||||
از نمایشگر لاگ داخلی (گزینه منو 4) یا دستورات دستی استفاده کنید:
|
||||
|
||||
```bash
|
||||
sudo ss -tulnp | grep -E "(5300|1080)" # نظارت بر تعداد اتصالات
|
||||
sudo systemctl status dnstt-server # بررسی منابع سرویس
|
||||
|
||||
@@ -32,6 +32,8 @@ Go into your name registrar's configuration panel and add these records:
|
||||
## Features
|
||||
|
||||
- **Multi-distribution support**: Fedora, Rocky Linux, CentOS, Debian, Ubuntu
|
||||
- **Interactive management menu**: Easy-to-use interface for all operations
|
||||
- **Self-updating capability**: Built-in update mechanism for the script
|
||||
- **Automatic detection**: OS, architecture, and SSH port detection
|
||||
- **Security hardened**: Non-root service execution with systemd security features
|
||||
- **Smart configuration**: Persistent settings and automatic key reuse
|
||||
@@ -50,20 +52,38 @@ Go into your name registrar's configuration panel and add these records:
|
||||
|
||||
### Installation
|
||||
|
||||
1. **Download the script:**
|
||||
```bash
|
||||
wget https://raw.githubusercontent.com/bugfloyd/dnstt-deploy/main/dnstt-deploy.sh
|
||||
```
|
||||
**One-command installation:**
|
||||
```bash
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/bugfloyd/dnstt-deploy/main/dnstt-deploy.sh)
|
||||
```
|
||||
|
||||
2. **Run the deployment:**
|
||||
```bash
|
||||
sudo ./dnstt-deploy.sh
|
||||
```
|
||||
This command will:
|
||||
1. Download and install the script to `/usr/local/bin/dnstt-deploy`
|
||||
2. Start the interactive setup process
|
||||
3. Configure your dnstt server automatically
|
||||
|
||||
3. **Follow the interactive prompts:**
|
||||
- Enter your nameserver subdomain (e.g., `t.example.com`)
|
||||
- Set MTU value (default: 1232)
|
||||
- Choose tunnel mode (SSH or SOCKS)
|
||||
### Post-Installation Usage
|
||||
|
||||
After installation, you can manage your dnstt server using the installed command:
|
||||
|
||||
```bash
|
||||
dnstt-deploy
|
||||
```
|
||||
|
||||
This will show an interactive menu with these options:
|
||||
|
||||
1. **Install/Reconfigure dnstt server** - Set up or modify configuration
|
||||
2. **Update dnstt-deploy script** - Check for and install script updates
|
||||
3. **Check service status** - View current service status
|
||||
4. **View service logs** - Monitor real-time logs (Ctrl+C to exit)
|
||||
5. **Exit** - Quit the menu
|
||||
|
||||
### Setup Process
|
||||
|
||||
During the setup (option 1), you'll be prompted for:
|
||||
- **Nameserver subdomain** (e.g., `t.example.com`)
|
||||
- **MTU value** (default: 1232)
|
||||
- **Tunnel mode** (SSH or SOCKS)
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -90,7 +110,12 @@ Go into your name registrar's configuration panel and add these records:
|
||||
- Restricted mobile networks: 512
|
||||
|
||||
### Changing Settings
|
||||
To change MTU or other settings, simply re-run the script and enter new values. The script will automatically update the configuration and restart services.
|
||||
To change MTU or other settings:
|
||||
1. Run `dnstt-deploy`
|
||||
2. Choose option 1 (Install/Reconfigure dnstt server)
|
||||
3. Enter new values when prompted
|
||||
|
||||
The script will automatically update the configuration and restart services.
|
||||
|
||||
## Client Usage
|
||||
|
||||
@@ -151,18 +176,35 @@ For SSH tunnels, you can use these Android/iOS apps without needing a computer:
|
||||
|
||||
## Management
|
||||
|
||||
### Management Menu
|
||||
|
||||
The easiest way to manage your dnstt server is through the interactive menu:
|
||||
|
||||
```bash
|
||||
dnstt-deploy
|
||||
```
|
||||
|
||||
This provides quick access to:
|
||||
- Server reconfiguration
|
||||
- Script updates
|
||||
- Service status monitoring
|
||||
- Real-time log viewing
|
||||
|
||||
### File Locations
|
||||
|
||||
```
|
||||
/usr/local/bin/dnstt-server # Main binary
|
||||
/etc/dnstt/ # Configuration directory
|
||||
├── dnstt-server.conf # Main configuration
|
||||
├── {domain}_server.key # Private key (per domain)
|
||||
└── {domain}_server.pub # Public key (per domain)
|
||||
/usr/local/bin/dnstt-deploy # Management script
|
||||
/usr/local/bin/dnstt-server # Main binary
|
||||
/etc/dnstt/ # Configuration directory
|
||||
├── dnstt-server.conf # Main configuration
|
||||
├── {domain}_server.key # Private key (per domain)
|
||||
└── {domain}_server.pub # Public key (per domain)
|
||||
/etc/systemd/system/dnstt-server.service # Systemd service
|
||||
```
|
||||
|
||||
### Service Commands
|
||||
### Manual Service Commands
|
||||
|
||||
If you prefer command-line management:
|
||||
|
||||
**dnstt-server Service**:
|
||||
```bash
|
||||
@@ -182,8 +224,31 @@ sudo systemctl restart danted # Restart service
|
||||
sudo journalctl -u danted -f # View logs
|
||||
```
|
||||
|
||||
### Updating the Script
|
||||
|
||||
The script can update itself in two ways:
|
||||
|
||||
**Method 1: Using the menu (recommended)**
|
||||
```bash
|
||||
dnstt-deploy
|
||||
# Choose option 2: Update dnstt-deploy script
|
||||
```
|
||||
|
||||
**Method 2: Re-run the curl command**
|
||||
```bash
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/bugfloyd/dnstt-deploy/main/dnstt-deploy.sh)
|
||||
# The script will detect and install updates automatically
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Using the Built-in Tools
|
||||
|
||||
The management menu provides quick access to troubleshooting tools:
|
||||
|
||||
1. **Check service status** (menu option 3): Shows if services are running properly
|
||||
2. **View service logs** (menu option 4): Real-time monitoring of service logs
|
||||
|
||||
### MTU Size Errors
|
||||
|
||||
If you see errors like this:
|
||||
@@ -191,12 +256,19 @@ If you see errors like this:
|
||||
FORMERR: requester payload size 512 is too small (minimum 1232)
|
||||
```
|
||||
|
||||
Lower the MTU to the mentioned number by re-running the script and entering the suggested MTU value. Consider the performance trade-offs when using very low MTU values.
|
||||
Lower the MTU to the mentioned number:
|
||||
1. Run `dnstt-deploy`
|
||||
2. Choose option 1 (Install/Reconfigure dnstt server)
|
||||
3. Enter the suggested MTU value when prompted
|
||||
|
||||
Consider the performance trade-offs when using very low MTU values.
|
||||
|
||||
### Common Issues
|
||||
|
||||
**Service Won't Start**:
|
||||
```bash
|
||||
dnstt-deploy # Use menu option 3 to check status
|
||||
# Or manually:
|
||||
sudo systemctl status dnstt-server # Check service status
|
||||
sudo journalctl -u dnstt-server -n 50 # Check logs for errors
|
||||
ls -la /usr/local/bin/dnstt-server # Verify binary permissions
|
||||
@@ -224,7 +296,11 @@ sudo ss -tulnp | grep 1080 # Check SOCKS proxy port (if enabled)
|
||||
|
||||
### Multiple Domain Support
|
||||
|
||||
The script supports multiple domains by generating separate key pairs for each domain. However, only one domain configuration can be active at a time since all configurations use port 53 for DNS traffic. To switch between domains, simply re-run the script with a different subdomain.
|
||||
The script supports multiple domains by generating separate key pairs for each domain. However, only one domain configuration can be active at a time since all configurations use port 53 for DNS traffic. To switch between domains:
|
||||
|
||||
1. Run `dnstt-deploy`
|
||||
2. Choose option 1 (Install/Reconfigure dnstt server)
|
||||
3. Enter the new subdomain when prompted
|
||||
|
||||
### DoH and DoT Support
|
||||
|
||||
@@ -232,6 +308,8 @@ For DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT) configurations, refer to the [off
|
||||
|
||||
### Performance Monitoring
|
||||
|
||||
Use the built-in log viewer (menu option 4) or manual commands:
|
||||
|
||||
```bash
|
||||
sudo ss -tulnp | grep -E "(5300|1080)" # Monitor connection count
|
||||
sudo systemctl status dnstt-server # Check service resources
|
||||
|
||||
+178
-5
@@ -20,12 +20,169 @@ NC='\033[0m' # No Color
|
||||
|
||||
# Global variables
|
||||
DNSTT_BASE_URL="https://dnstt.network"
|
||||
SCRIPT_URL="https://raw.githubusercontent.com/bugfloyd/dnstt-deploy/main/dnstt-deploy.sh"
|
||||
INSTALL_DIR="/usr/local/bin"
|
||||
CONFIG_DIR="/etc/dnstt"
|
||||
SYSTEMD_DIR="/etc/systemd/system"
|
||||
DNSTT_PORT="5300"
|
||||
DNSTT_USER="dnstt"
|
||||
CONFIG_FILE="${CONFIG_DIR}/dnstt-server.conf"
|
||||
SCRIPT_INSTALL_PATH="/usr/local/bin/dnstt-deploy"
|
||||
|
||||
# Function to install/update the script itself
|
||||
install_script() {
|
||||
print_status "Installing/updating dnstt-deploy script..."
|
||||
|
||||
# Download the latest version
|
||||
local temp_script="/tmp/dnstt-deploy-new.sh"
|
||||
curl -Ls "$SCRIPT_URL" -o "$temp_script"
|
||||
|
||||
# Make it executable
|
||||
chmod +x "$temp_script"
|
||||
|
||||
# Check if we're updating an existing installation
|
||||
if [ -f "$SCRIPT_INSTALL_PATH" ]; then
|
||||
# Compare checksums to see if update is needed
|
||||
local current_checksum
|
||||
local new_checksum
|
||||
current_checksum=$(sha256sum "$SCRIPT_INSTALL_PATH" | cut -d' ' -f1)
|
||||
new_checksum=$(sha256sum "$temp_script" | cut -d' ' -f1)
|
||||
|
||||
if [ "$current_checksum" = "$new_checksum" ]; then
|
||||
print_status "Script is already up to date"
|
||||
rm "$temp_script"
|
||||
return 0
|
||||
else
|
||||
print_status "Updating existing script installation..."
|
||||
fi
|
||||
else
|
||||
print_status "Installing script for the first time..."
|
||||
fi
|
||||
|
||||
# Copy to installation directory
|
||||
cp "$temp_script" "$SCRIPT_INSTALL_PATH"
|
||||
rm "$temp_script"
|
||||
|
||||
print_status "Script installed to $SCRIPT_INSTALL_PATH"
|
||||
print_status "You can now run 'dnstt-deploy' from anywhere"
|
||||
}
|
||||
|
||||
# Function to handle manual update
|
||||
update_script() {
|
||||
print_status "Checking for script updates..."
|
||||
|
||||
local temp_script="/tmp/dnstt-deploy-latest.sh"
|
||||
if ! curl -Ls "$SCRIPT_URL" -o "$temp_script"; then
|
||||
print_error "Failed to download latest version"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local current_checksum
|
||||
local latest_checksum
|
||||
current_checksum=$(sha256sum "$SCRIPT_INSTALL_PATH" | cut -d' ' -f1)
|
||||
latest_checksum=$(sha256sum "$temp_script" | cut -d' ' -f1)
|
||||
|
||||
if [ "$current_checksum" = "$latest_checksum" ]; then
|
||||
print_status "You are already running the latest version"
|
||||
rm "$temp_script"
|
||||
return 0
|
||||
fi
|
||||
|
||||
print_status "New version available! Updating..."
|
||||
chmod +x "$temp_script"
|
||||
cp "$temp_script" "$SCRIPT_INSTALL_PATH"
|
||||
rm "$temp_script"
|
||||
print_status "Script updated successfully!"
|
||||
print_status "Changes will take effect on next run"
|
||||
}
|
||||
|
||||
# Function to show main menu
|
||||
show_menu() {
|
||||
echo ""
|
||||
print_status "dnstt Server Management"
|
||||
print_status "======================="
|
||||
echo "1) Install/Reconfigure dnstt server"
|
||||
echo "2) Update dnstt-deploy script"
|
||||
echo "3) Check service status"
|
||||
echo "4) View service logs"
|
||||
echo "5) Exit"
|
||||
echo ""
|
||||
print_question "Please select an option (1-5): "
|
||||
}
|
||||
|
||||
# Function to handle menu selection
|
||||
handle_menu() {
|
||||
while true; do
|
||||
show_menu
|
||||
read -r choice
|
||||
|
||||
case $choice in
|
||||
1)
|
||||
print_status "Starting dnstt server installation/reconfiguration..."
|
||||
return 0 # Continue with main installation
|
||||
;;
|
||||
2)
|
||||
update_script
|
||||
;;
|
||||
3)
|
||||
if systemctl is-active --quiet dnstt-server; then
|
||||
print_status "dnstt-server service is running"
|
||||
systemctl status dnstt-server --no-pager -l
|
||||
else
|
||||
print_warning "dnstt-server service is not running"
|
||||
systemctl status dnstt-server --no-pager -l
|
||||
fi
|
||||
;;
|
||||
4)
|
||||
print_status "Showing dnstt-server logs (Press Ctrl+C to exit)..."
|
||||
journalctl -u dnstt-server -f
|
||||
;;
|
||||
5)
|
||||
print_status "Goodbye!"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
print_error "Invalid choice. Please enter 1-5."
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$choice" != "4" ]; then
|
||||
echo ""
|
||||
print_question "Press Enter to continue..."
|
||||
read -r
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Function to check for script updates
|
||||
check_for_updates() {
|
||||
# Only check for updates if we're running from the installed location
|
||||
if [ "$0" = "$SCRIPT_INSTALL_PATH" ]; then
|
||||
print_status "Checking for script updates..."
|
||||
|
||||
local temp_script="/tmp/dnstt-deploy-latest.sh"
|
||||
if curl -Ls "$SCRIPT_URL" -o "$temp_script"; then
|
||||
local current_checksum
|
||||
local latest_checksum
|
||||
current_checksum=$(sha256sum "$SCRIPT_INSTALL_PATH" | cut -d' ' -f1)
|
||||
latest_checksum=$(sha256sum "$temp_script" | cut -d' ' -f1)
|
||||
|
||||
if [ "$current_checksum" != "$latest_checksum" ]; then
|
||||
print_status "New version available! Updating..."
|
||||
chmod +x "$temp_script"
|
||||
cp "$temp_script" "$SCRIPT_INSTALL_PATH"
|
||||
rm "$temp_script"
|
||||
print_status "Script updated successfully. Restarting with new version..."
|
||||
exec "$SCRIPT_INSTALL_PATH" "$@"
|
||||
else
|
||||
print_status "Script is up to date"
|
||||
rm "$temp_script"
|
||||
fi
|
||||
else
|
||||
print_warning "Could not check for updates (network issue)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to load existing configuration
|
||||
load_existing_config() {
|
||||
@@ -58,6 +215,7 @@ EOF
|
||||
chown root:"$DNSTT_USER" "$CONFIG_FILE"
|
||||
print_status "Configuration saved to $CONFIG_FILE"
|
||||
}
|
||||
|
||||
print_status() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
@@ -650,11 +808,14 @@ display_final_info() {
|
||||
print_status "Public key content:"
|
||||
cat "$PUBLIC_KEY_FILE"
|
||||
print_status ""
|
||||
print_status "Service management commands:"
|
||||
print_status " Start: systemctl start dnstt-server"
|
||||
print_status " Stop: systemctl stop dnstt-server"
|
||||
print_status " Status: systemctl status dnstt-server"
|
||||
print_status " Logs: journalctl -u dnstt-server -f"
|
||||
print_status "Script installed at: $SCRIPT_INSTALL_PATH"
|
||||
print_status ""
|
||||
print_status "Management commands:"
|
||||
print_status " Run menu: dnstt-deploy"
|
||||
print_status " Start service: systemctl start dnstt-server"
|
||||
print_status " Stop service: systemctl stop dnstt-server"
|
||||
print_status " Service status: systemctl status dnstt-server"
|
||||
print_status " View logs: journalctl -u dnstt-server -f"
|
||||
|
||||
if [ "$TUNNEL_MODE" = "socks" ]; then
|
||||
print_status ""
|
||||
@@ -669,6 +830,18 @@ display_final_info() {
|
||||
|
||||
# Main function
|
||||
main() {
|
||||
# Check for updates if running from installed location (auto-update for curl installs)
|
||||
check_for_updates "$@"
|
||||
|
||||
# Install/update the script itself if not running from installed location
|
||||
if [ "$0" != "$SCRIPT_INSTALL_PATH" ]; then
|
||||
print_status "Starting dnstt server setup..."
|
||||
install_script
|
||||
else
|
||||
# Running from installed location - show menu
|
||||
handle_menu
|
||||
fi
|
||||
|
||||
print_status "Starting dnstt server setup..."
|
||||
|
||||
# Check and install required tools
|
||||
|
||||
Reference in New Issue
Block a user