-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathsetup
More file actions
114 lines (100 loc) · 3.02 KB
/
setup
File metadata and controls
114 lines (100 loc) · 3.02 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
#ALONE CODER
#!/bin/bash
pprint() {
local msg="$1" c="$2" r="\033[0m"
case "$c" in
cred) c="\033[0;31m";; cgreen) c="\033[0;32m";;
cyellow) c="\033[0;33m";; cblue) c="\033[0;34m";;
*) c="\033[0;35m";;
esac
printf "%b%b%b" "$c" "$msg" "$r"
}
color_reset() { printf '\033[0m'; }
[ "$EUID" -ne 0 ] && { pprint "You need sudo privileges. Exiting...\n" "cred"; exit 1; }
yesnoprompt() {
stty raw -echo
answer=$(head -c1)
stty sane
[[ "$answer" =~ [Yy] ]]
}
update() {
pprint "\n\nUpdating package list... "
if sudo apt update 2>&1 | grep -q "can be upgraded"; then
pprint "Update available. Upgrade (y/n)? " "cyellow"
yesnoprompt && {
pprint "\nUpgrading... "
if sudo apt upgrade -y &>/dev/null; then
pprint "Done.\n\n" "cgreen"
else
pprint "Failed.\n\n" "cred"
fi
} || echo
else
pprint "Already up-to-date.\n\n" "cgreen"
fi
}
install_pkg() {
command -v "$1" &>/dev/null || {
pprint "$1 not found, installing... "
sudo apt install -y "$2" &>/dev/null && pprint "Done.\n\n" "cgreen" || pprint "Failed.\n\n" "cred"
}
}
install_deno() {
pprint "\n\nInstalling Deno...\n" "cblue"
if command -v deno &>/dev/null; then
pprint "Deno already installed.\n" "cgreen"
else
curl -fsSL https://deno.land/install.sh | sh >/dev/null 2>&1
deno_path="$HOME/.deno/bin"
if [[ ":$PATH:" != *":$deno_path:"* ]]; then
echo "export DENO_INSTALL=\"$HOME/.deno\"" >> ~/.bashrc
echo "export PATH=\"\$DENO_INSTALL/bin:\$PATH\"" >> ~/.bashrc
pprint "Deno path added to ~/.bashrc\n" "cyellow"
fi
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
pprint "Deno installation complete.\n" "cgreen"
fi
}
install_py() {
pprint "\n\nInstalling Python dependencies...\n"
if pip3 install -U pip -q && pip3 install -U -r requirements.txt -q; then
pprint "Done.\n" "cgreen"
else
pprint "Failed (continuing...)\n" "cred"
fi
}
save_env_vars() {
pprint "\n\nProcessing your variables..." "cgreen"
[ -f .env ] && rm .env
cat >.env <<EOF
API_ID=$1
API_HASH=$2
BOT_TOKEN=$3
MONGO_URL=$4
LOGGER_ID=$5
SESSION=$6
OWNER_ID=$7
EOF
}
clear
pprint "Welcome to the AloneXMusic Installation Setup\n\n" "cmagenta"
sleep 1
update
install_pkg python3-pip python3-pip
install_pkg ffmpeg ffmpeg unzip
install_deno
install_py
pprint "\nAloneXMusic Installation Completed.\n" "cgreen"
sleep 2
clear
pprint "\nEnter Your Values Below\n\n\n" "cmagenta"
read -rp "API ID: " api_id
read -rp "API HASH: " api_hash
read -rp "BOT TOKEN: " bot_token
read -rp "OWNER ID: " ownid
read -rp "MONGO URL: " mongo_db
read -rp "LOG GROUP ID: " logger
read -rp "STRING SESSION: " string_session
save_env_vars "$api_id" "$api_hash" "$bot_token" "$mongo_db" "$logger" "$string_session" "$ownid"
pprint "\nYour variables have been saved! Start bot with: bash start\n" "cgreen"