-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
38 lines (31 loc) · 1007 Bytes
/
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
#!/bin/bash
sudo chmod 666 /root/.bashrc
add_alias() {
local user="$1"
local alias_line="alias ypg='python $script_dir/main.py'"
local bashrc_file="/home/$user/.bashrc"
if [ "$user" = "root" ]; then
bashrc_file="/root/.bashrc"
fi
if [ -f "$bashrc_file" ]; then
if ! grep -qF "$alias_line" "$bashrc_file"; then
echo "$alias_line" >> "$bashrc_file"
echo "Installed, run 'ypg' to see"
else
echo "Already installed at $user."
fi
else
echo "The $bashrc_file from $user can't be created. Run install.sh with sudo"
fi
}
if [[ "$(uname -s)" == "Linux" ]]; then
# Obtém o diretório do script em execução
script_dir="$(dirname "$(readlink -f "$0")")"
echo "Installed, run 'ypg' to see"
add_alias "$USER"
add_alias "root"
elif [[ "$(uname -s)" == "MINGW"* ]]; then
echo "Non-supported OS, pls use Unix distros"
else
echo "Non-supported OS, pls use Unix distros"
fi