Skip to content
This repository was archived by the owner on Nov 2, 2025. It is now read-only.

Commit 45bf85a

Browse files
committed
Refactor scripts and traefik
1 parent e0ce367 commit 45bf85a

File tree

9 files changed

+505
-112
lines changed

9 files changed

+505
-112
lines changed

.env.example

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ BOT_DOMAIN=3xui-shop.com
66
XUI_USERNAME=admin
77
XUI_PASSWORD=admin
88

9-
CF_API_KEY=key
10-
CF_API_EMAIL=[email protected]
9+
LETSENCRYPT_EMAIL=[email protected]

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,6 @@ cython_debug/
171171
*.gz
172172

173173
# Plans
174-
plans.json
174+
plans.json
175+
176+
tmp_test/

README.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Before starting the installation, make sure you have the installed [**Docker**](
102102

103103
1. **Clone the repository:**
104104
```bash
105-
git clone https://github.com/snoups/3xui-shop.git
105+
bash <(curl -Ls https://raw.githubusercontent.com/snoups/3xui-shop/main/scripts/install.sh) -q
106106
cd 3xui-shop
107107
```
108108

@@ -130,6 +130,8 @@ Before starting the installation, make sure you have the installed [**Docker**](
130130

131131
| Variable | Required | Default | Description |
132132
|-|-|-|-|
133+
| LETSENCRYPT_EMAIL | 🔴 | - | Email for generating certificates |
134+
| | | |
133135
| BOT_TOKEN | 🔴 | - | Telegram bot token |
134136
| BOT_ADMINS || - | List of admin IDs (e.g., 123456789,987654321) |
135137
| BOT_DEV_ID | 🔴 | - | ID of the bot developer |
@@ -167,9 +169,7 @@ Before starting the installation, make sure you have the installed [**Docker**](
167169
| LOG_LEVEL || DEBUG | Log level (e.g., INFO, DEBUG) |
168170
| LOG_FORMAT || %(asctime)s \| %(name)s \| %(levelname)s \| %(message)s | Log format |
169171
| LOG_ARCHIVE_FORMAT || zip | Log archive format (e.g., zip, gz) |
170-
| | | |
171-
| CF_API_KEY | 🔴 | - | Cloudflare API key |
172-
| CF_API_EMAIL | 🔴 | - | Cloudflare API email |
172+
173173

174174
### Subscription Plans Configuration
175175

@@ -209,23 +209,6 @@ Before starting the installation, make sure you have the installed [**Docker**](
209209
}
210210
```
211211

212-
### Cloudflare Configuration
213-
214-
1. **Domain and SSL/TLS Setup:**
215-
216-
- Add an A record in the DNS section:
217-
- Name: Your bot’s subdomain (e.g., bot)
218-
- IPv4 address: Your server’s IP address
219-
- Proxy status: DNS only (disable proxy)
220-
- Enable Full (strict) SSL/TLS mode under the SSL/TLS section.
221-
222-
2. **Environment Variables Setup:**
223-
224-
- Visit the [API Tokens](https://dash.cloudflare.com/profile/api-tokens) page.
225-
- Click `View Global API Key` and set:
226-
- `CF_API_KEY`: Your global API key
227-
- `CF_API_EMAIL`: Your Cloudflare email
228-
229212
### YooKassa Configuration
230213

231214
1. **Webhook Setup:**
@@ -259,10 +242,10 @@ Before starting the installation, make sure you have the installed [**Docker**](
259242

260243
To ensure the bot functions correctly, you must configure the 3X-UI panel:
261244

262-
- [Set up SSL certificates from Cloudflare.](https://github.com/MHSanaei/3x-ui?tab=readme-ov-file#ssl-certificate)
245+
- [Set up SSL certificate.](https://github.com/MHSanaei/3x-ui?tab=readme-ov-file#ssl-certificate)
263246
- Set up an Inbound **(the first one will be used)** for adding clients.
264247
- Enable the subscription service with port `2096` and path `/user/`.
265-
> **Don’t forget to specify certificates for the subscription.**
248+
> **Don’t forget to specify certificate for the subscription.**
266249
- Disabling configuration encryption is recommended.
267250

268251
<a id="bugs-and-feature-requests"></a>

docker-compose.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ services:
88
- "443:443"
99
env_file:
1010
- .env
11-
environment:
12-
- CLOUDFLARE_API_KEY=${CF_API_KEY}
13-
- CLOUDFLARE_API_EMAIL=${CF_API_EMAIL}
1411
volumes:
1512
- "/var/run/docker.sock:/var/run/docker.sock:ro"
1613
- "letsencrypt_data:/letsencrypt"
@@ -19,9 +16,9 @@ services:
1916
- "--entrypoints.websecure.address=:443"
2017
- "--providers.docker=true"
2118
- "--providers.docker.exposedbydefault=false"
22-
- "--certificatesresolvers.letsencrypt.acme.email=${CF_API_EMAIL}"
19+
- "--certificatesresolvers.letsencrypt.acme.email=${LETSENCRYPT_EMAIL}"
2320
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
24-
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.provider=cloudflare"
21+
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
2522
- "--log.level=INFO"
2623
labels:
2724
- "traefik.enable=true"

scripts/delete_logs.sh

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,54 @@
11
#!/bin/bash
2-
# Script to delete .log files in a specified directory.
32

4-
# Default directory for logs
3+
# delete_logs.sh
4+
# -----------------------------------------------------------------------------
5+
# Script to delete .log, .zip, and .gz files from a specified directory.
6+
#
7+
# Options:
8+
# --dir PATH Specify the directory to clean logs and archives from (default: app/logs).
9+
# --help Display this help message.
10+
# -----------------------------------------------------------------------------
11+
512
DEFAULT_LOG_DIR="app/logs"
13+
LOG_DIR="$DEFAULT_LOG_DIR"
14+
15+
show_help() {
16+
grep '^#' "$0" | cut -c 5-
17+
}
618

7-
# Use the provided directory path or default to the predefined one
8-
LOG_DIR="${1:-$DEFAULT_LOG_DIR}"
19+
while [[ $# -gt 0 ]]; do
20+
case "$1" in
21+
--dir)
22+
shift
23+
if [[ -n "$1" ]]; then
24+
LOG_DIR="$1"
25+
shift
26+
else
27+
echo "❌ Error: --dir flag requires a directory path." >&2
28+
exit 1
29+
fi
30+
;;
31+
--help)
32+
show_help
33+
exit 0
34+
;;
35+
*)
36+
echo "❌ Error: Unknown option '$1'. Use --help for usage information." >&2
37+
exit 1
38+
;;
39+
esac
40+
done
941

10-
# Check if the directory exists
11-
if [ -d "$LOG_DIR" ]; then
12-
echo "Looking for .log files in: $LOG_DIR"
13-
14-
# Find and delete all .log files
15-
find "$LOG_DIR" -type f -name "*.log" -exec rm -f {} +
42+
if [[ -d "$LOG_DIR" ]]; then
43+
echo "🔍 Searching for .log, .zip, and .gz files in: $LOG_DIR"
1644

17-
# Verify if deletion succeeded
18-
if [ $? -eq 0 ]; then
19-
echo "All .log files were successfully deleted from: $LOG_DIR"
45+
if find "$LOG_DIR" -type f \( -name "*.log" -o -name "*.zip" -o -name "*.gz" \) -exec rm -f {} +; then
46+
echo "✅ All .log, .zip, and .gz files were successfully deleted from: $LOG_DIR"
2047
else
21-
echo "Error: Failed to delete some .log files." >&2
48+
echo " Failed to delete some files." >&2
2249
exit 1
2350
fi
2451
else
25-
echo "Error: Directory '$LOG_DIR' does not exist." >&2
52+
echo " Directory '$LOG_DIR' does not exist." >&2
2653
exit 1
2754
fi

0 commit comments

Comments
 (0)