This repository has been archived by the owner on Sep 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
77 lines (63 loc) · 1.73 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
#/bin/bash
DIRINSTALL=~/.ywr
CURRENTDIR="${BASH_SOURCE%/*}"
USEREXISTS="{
\"exists\": true
}"
R="$(tput setaf 1)"
RESET="$(tput sgr0)"
if [[ ! -d "$CURRENTDIR" ]]; then CURRENTDIR="$PWD"; fi
install_ywr () {
rm -rf $DIRINSTALL
mkdir $DIRINSTALL
cp $CURRENTDIR/ywr.py $DIRINSTALL/
cp $CURRENTDIR/ywr.conf $DIRINSTALL/
cp $CURRENTDIR/confywr.sh $DIRINSTALL/
cp -r $CURRENTDIR/requests $DIRINSTALL/
cp $CURRENTDIR/ywr $DIRINSTALL/
if [[ $UID != 0 ]]; then
echo ""
echo -e "${R}Why you no sudo?"
echo -e "No worries, I got you covered. I can do this sudo thing too!"
echo -e "Just enter your root password:${RESET}"
sudo chmod +x $DIRINSTALL/ywr
else
chmod +x $DIRINSTALL/ywr
fi
touch ~/.bash_profile
echo \#ywr >> ~/.bash_profile
echo export PATH=\$PATH:$DIRINSTALL/ >> ~/.bash_profile
export PATH=$PATH:$DIRINSTALL/
echo -e "I need your username for YO!"
while true; do
echo -n "Username: "
read username
STATUS=$(curl -s "https://api.justyo.co/check_username/?api_token=ef63a4f2-548a-46ef-924e-7141e0af2358&username=$username")
if [ "$STATUS" == "$USEREXISTS" ]
then
echo "User exists!"
sudo echo Username = $username >> ~/.ywr/ywr.conf
break
else
echo "User does not exists."
fi
done
echo ""
echo "To use ywr just type 'ywr' followed by any command of your choice."
echo "Example:"
echo "--------"
echo "ywr sudo npm install -g express"
echo "--------"
echo "Or just type ywr -t to test your configuration."
echo ""
echo "Type 'ywr -c' to reconfigure yo."
}
while true; do
read -p "You are about to install ywr. Continue? Y/n " yn
case $yn in
[Yy]* ) install_ywr
break;;
* ) echo "Installation aborted!"
break;;
esac
done