-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·134 lines (113 loc) · 2.56 KB
/
install.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
#!/bin/bash
# MusPlayer
# Version : 1.0
# Author : KasRoudra
# Github : https://github.com/KasRoudra
# Email : [email protected]
# Contact : https://m.me/KasRoudra
# Description: Play music in terminal.
# Music player for terminal
black="\033[0;30m"
red="\033[0;31m"
green="\033[0;32m"
yellow="\033[0;33m"
blue="\033[0;34m"
purple="\033[0;35m"
cyan="\033[0;36m"
white="\033[0;37m"
nc="\033[00m"
version="1.1"
logo="${green} __ __ ____ _
${red}| \/ |_ _ ___| _ \| | __ _ _ _ ___ _ __
${blue}| |\/| | | | / __| |_) | |/ _' | | | |/ _ \ '__|
${yellow}| | | | |_| \__ \ __/| | (_| | |_| | __/ |
${purple}|_| |_|\__,_|___/_| |_|\__,_|\__, |\___|_|
${cyan} |___/ [v${version}]
${red} [By KasRoudra]${nc}
"
color=0
info() {
if (( $color % 2 == 0 )) ; then
echo -e "${yellow}[${white}*${yellow}] ${cyan}${1}${nc}\n"
else
echo -e "${green}[${white}+${green}] ${purple}${1}${nc}\n"
fi
(( color++ ))
sleep 1
}
ask() {
printf "${yellow}[${white}?${yellow}] ${blue}${1}${green}"
sleep 1
}
success() {
echo -e "${cyan}[${white}✔${cyan}] ${green}${1}${nc}\n"
sleep 1
}
error() {
echo -e "${blue}[${white}✘${blue}] ${red}${1}\007${nc}\n"
sleep 1
}
handle_interrupt() {
success "Thanks for using. Have a good day!"
exit 0
}
doas() {
# Check for sudo
if [ -x "$(command -v sudo)" ]; then
sudo $@
else
eval $@
fi
}
get_path() {
target_path=$(echo $PATH)
paths=$(echo $PATH | awk -F: '{ for (i=1; i<=NF; i++) {print $i}}')
if [[ "$PATH" =~ ":" ]]; then
target_path=$(echo "$PATH" | cut -d ":" -f1)
fi
for path in $paths; do
if [[ "$path" =~ "/usr/bin" ]]; then
target_path="$path"
break
fi
done
echo "$target_path"
}
welcome() {
clear
if [ -n $(command -v lolcat) ]; then
echo -e "$logo" | lolcat
else
echo -e "$logo"
fi
}
installer() {
info "Installing files......."
path=$(get_path)
target="$path/musplayer"
if ! [ -f "musplayer.sh" ]; then
curl https://raw.githubusercontent.com/KasRoudra/Musplayer/main/musplayer.sh -o musplayer.sh
fi
if [ -n "$path" ]; then
doas cp musplayer.sh "$target"
doas chmod 777 "$target"
else
error "Cannot determine path. Move file to path manually"
fi
}
final() {
path=$(get_path)
target="$path/musplayer"
if [ -e "$target" ]; then
success "Musplayer has installed successfully."
success "Run 'musplayer' to start it!"
else
error "Failed to install Musplayer"
fi
}
main() {
welcome
installer
final
}
main