-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtgupload
More file actions
executable file
·67 lines (53 loc) · 1.47 KB
/
tgupload
File metadata and controls
executable file
·67 lines (53 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# TGManager Upload Helper Script
# This script ensures you're always in a valid directory when running uploads
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
UPLOADER_BIN="${SCRIPT_DIR}/dist/uploader-linux"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored messages
print_info() {
echo -e "${BLUE}ℹ${NC} $1"
}
print_success() {
echo -e "${GREEN}✓${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
# Check if uploader binary exists
if [ ! -f "$UPLOADER_BIN" ]; then
print_error "Uploader binary not found at $UPLOADER_BIN"
echo "Please build the project first: npm run build-native"
exit 1
fi
# Make sure binary is executable
chmod +x "$UPLOADER_BIN" 2>/dev/null
# Ensure we're in a valid directory
if ! pwd > /dev/null 2>&1; then
print_warning "Current directory no longer exists, changing to home directory"
cd ~ || cd /tmp || {
print_error "Cannot change to a valid directory"
exit 1
}
fi
# Show current directory
print_info "Running from: $(pwd)"
# Run the uploader with all arguments
"$UPLOADER_BIN" "$@"
EXIT_CODE=$?
# Show result
if [ $EXIT_CODE -eq 0 ]; then
print_success "Operation completed successfully"
else
print_error "Operation failed with exit code $EXIT_CODE"
fi
exit $EXIT_CODE