-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
127 lines (106 loc) · 3.16 KB
/
Copy pathinstall.sh
File metadata and controls
127 lines (106 loc) · 3.16 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
clear
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'
BOLD='\033[1m'
# check root
[[ $EUID -ne 0 ]] && echo -e "${red}${BOLD}Fatal error: ${yellow} Please run this script with root privilege \n " && exit 1
# Loading effect
loading() {
echo -ne "${yellow}${BOLD} * ALEFBEMEDIA Uptime Service."
sleep 1
echo -ne "\r${yellow}${BOLD} * ALEFBEMEDIA Uptime Service.."
sleep 1
echo -ne "\r${yellow}${BOLD} * ALEFBEMEDIA Uptime Service...${plain}"
sleep 1
echo -ne "\n"
}
loading
# Set DNS temporarily for Docker installation
systemctl start systemd-resolved
systemctl enable systemd-resolved
interface=$(ip route | grep default | awk '{print $5}')
resolvectl dns $interface 178.22.122.100 185.51.200.2
echo -e "nameserver 178.22.122.100\nnameserver 185.51.200.2" > /etc/resolv.conf
# Navigate to root directory
cd ~
# Check if Docker is installed
if ! command -v docker &> /dev/null
then
echo -e "${red}Docker is Offline ❌"
sleep 1
echo -e "${yellow}${BOLD}Installing Docker...${plain}"
curl -fsSL https://get.docker.com | sh
fi
# Check if Docker is installed
if ! command -v docker &> /dev/null
then
snap install docker
fi
# Check if Docker is installed
if command -v docker &> /dev/null; then
echo -e "${green}Docker is Online ✅${plain}"
else
echo -e "${red}Docker failed to install ❌${plain}"
exit 1
fi
sleep 1
# delete docker container
CONTAINER_NAME="uptime-kuma"
if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
docker stop uptime-kuma
docker rm uptime-kuma
fi
# port selection
default_port=3001
while true; do
# Prompt the user for input
read -p "Enter port number [default: $default_port]: " port
# Use default value if no input is provided
port=${port:-$default_port}
# Check if the port is in use
if lsof -i :$port > /dev/null; then
echo -e "${red}Error: Port $port is already in use${plain}"
else
echo -e "Using port: $port"
break
fi
done
# delete AlefbeMedia_uptime Directory
if [ -d "AlefbeMedia_uptime" ]; then
rm -r AlefbeMedia_uptime
fi
# Create and navigate to AlefbeMedia_uptime directory
mkdir -p AlefbeMedia_uptime && cd AlefbeMedia_uptime
# Create docker-compose.yml file
cat <<EOL > docker-compose.yml
# @Alefbemedia Uptime Service for Xray Configs
services:
uptime-kuma:
image: louislam/uptime-kuma:1
container_name: uptime-kuma
restart: always
ports:
- "$port:3001"
volumes:
- uptime-kuma:/app/data
volumes:
uptime-kuma:
EOL
# Start the Docker service
docker compose up -d
# X-UI check
if ! command -v x-ui &> /dev/null
then
echo -e "${red}Now Please Install X-UI Pannel >> ${plain}bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)"
fi
echo -e "\n${BOLD}* ALEFBEMEDIA Uptime Service is Online ✅"
server_ip=$(curl -s https://api.ipify.org)
echo -e "${yellow}> Access URL: ${plain}http://${server_ip}:$port \n"
echo -e "${yellow}+ Alefbemedia Telegram Channel: ${plain}https://t.me/+VXskKuUuOBEPUB8i \n"
# Reset DNS to default
resolvectl dns $interface 8.8.8.8 8.8.4.4
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4" > /etc/resolv.conf
exit 1