forked from deathline94/Juicity-Installer
-
Notifications
You must be signed in to change notification settings - Fork 142
/
juicity-installer.sh
183 lines (163 loc) · 4.54 KB
/
juicity-installer.sh
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
# Variables
INSTALL_DIR="/root/juicity"
CONFIG_FILE="$INSTALL_DIR/config.json"
SERVICE_FILE="/etc/systemd/system/juicity.service"
JUICITY_SERVER="$INSTALL_DIR/juicity-server"
# Function to print characters with delay
print_with_delay() {
text="$1"
delay="$2"
for ((i = 0; i < ${#text}; i++)); do
echo -n "${text:$i:1}"
sleep $delay
done
echo
}
# Introduction animation
echo ""
echo ""
print_with_delay "juicity-installer by DEATHLINE | @NamelesGhoul" 0.1
echo ""
echo ""
# Install required packages
sudo apt-get update > /dev/null 2>&1
sudo apt-get install -y unzip jq uuid-runtime > /dev/null 2>&1
# Check for an existing installation
if [[ -d $INSTALL_DIR && -f $SERVICE_FILE ]]; then
echo "Juicity already installed. Choose an option:"
echo ""
echo ""
echo "1. Reinstall"
echo ""
echo "2. Modify"
echo ""
echo "3. Uninstall"
echo ""
read -p "Enter your choice (1/2/3): " choice
case $choice in
1)
echo "Reinstalling..."
sudo systemctl stop juicity
sudo systemctl disable juicity > /dev/null 2>&1
rm -rf $INSTALL_DIR
rm -f $SERVICE_FILE
;;
2)
read -p "Enter new listen port: " PORT
sed -i "s/\"listen\": \":.*\"/\"listen\": \":$PORT\"/" $CONFIG_FILE
sudo systemctl restart juicity
SHARE_LINK=$($JUICITY_SERVER generate-sharelink -c $CONFIG_FILE)
echo "New Share Link: $SHARE_LINK"
exit 0
;;
3)
sudo systemctl stop juicity
sudo systemctl disable juicity > /dev/null 2>&1
rm -rf $INSTALL_DIR
rm -f $SERVICE_FILE
echo "Uninstalled successfully!"
exit 0
;;
*)
echo "Invalid choice!"
exit 1
;;
esac
fi
# Detect Architecture
ARCH=$(uname -m)
BINARY_NAME="juicity-linux"
case "$ARCH" in
"x86_64")
BINARY_NAME+="-x86_64.zip"
;;
"arm64")
BINARY_NAME+="-arm64.zip"
;;
"armv7")
BINARY_NAME+="-armv7.zip"
;;
"mips32")
BINARY_NAME+="-mips32.zip"
;;
"mips64")
BINARY_NAME+="-mips64.zip"
;;
"riscv64")
BINARY_NAME+="-riscv64.zip"
;;
"i686")
BINARY_NAME+="-x86_32.zip"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
LATEST_RELEASE_URL=$(curl --silent "https://api.github.com/repos/juicity/juicity/releases" | jq -r ".[0].assets[] | select(.name == \"$BINARY_NAME\") | .browser_download_url")
# Download and extract
mkdir -p $INSTALL_DIR
curl -sL $LATEST_RELEASE_URL -o "$INSTALL_DIR/juicity.zip"
unzip -q "$INSTALL_DIR/juicity.zip" -d $INSTALL_DIR
# Delete all files except juicity-server
find $INSTALL_DIR ! -name 'juicity-server' -type f -exec rm -f {} +
# Set permissions
chmod +x $JUICITY_SERVER
# Create config.json
echo ""
read -p "Enter listen port (or press enter to randomize between 10000 and 65535): " PORT
echo ""
[[ -z "$PORT" ]] && PORT=$((RANDOM % 55536 + 10000))
echo ""
read -p "Enter password (or press enter to generate one): " PASSWORD
echo ""
if [[ -z "$PASSWORD" ]]; then
PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
echo "Generated Password: $PASSWORD"
fi
UUID=$(uuidgen)
# Generate keys
openssl ecparam -genkey -name prime256v1 -out "$INSTALL_DIR/private.key"
openssl req -new -x509 -days 36500 -key "$INSTALL_DIR/private.key" -out "$INSTALL_DIR/fullchain.cer" -subj "/CN=www.speedtest.net"
cat > $CONFIG_FILE <<EOL
{
"listen": ":$PORT",
"users": {
"$UUID": "$PASSWORD"
},
"certificate": "$INSTALL_DIR/fullchain.cer",
"private_key": "$INSTALL_DIR/private.key",
"congestion_control": "bbr",
"log_level": "info"
}
EOL
# Create systemd service file
cat > $SERVICE_FILE <<EOL
[Unit]
Description=juicity-server Service
Documentation=https://github.com/juicity/juicity
After=network.target nss-lookup.target
[Service]
Type=simple
User=root
ExecStart=$JUICITY_SERVER run -c $CONFIG_FILE
StandardOutput=file:$INSTALL_DIR/juicity-server.log
StandardError=file:$INSTALL_DIR/juicity-server.log
Restart=on-failure
LimitNPROC=512
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
EOL
# Reload systemd, enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable juicity > /dev/null 2>&1
sudo systemctl start juicity
# Modified share link output
SHARE_LINK=$($JUICITY_SERVER generate-sharelink -c $CONFIG_FILE)
echo ""
echo ""
echo "$SHARE_LINK"
echo ""
echo ""