forked from anandslab/AtoMiC-ToolKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_aliases-installer.sh
executable file
·110 lines (89 loc) · 3.88 KB
/
bash_aliases-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
#!/bin/bash
# Script Name: AtoMiC .bash_aliases Installer
# Author: htpcBeginner
# Publisher: http://www.htpcBeginner.com
# License: MIT License (refer to README.md for more details)
#
# DO NOT EDIT ANYTHING UNLESS YOU KNOW WHAT YOU ARE DOING.
YELLOW='\e[93m'
RED='\e[91m'
ENDCOLOR='\033[0m'
CYAN='\e[96m'
GREEN='\e[92m'
SCRIPTPATH=$(pwd)
function pause(){
read -p "$*"
}
clear
echo
echo -e $RED
echo -e " ┬ ┬┬ ┬┬ ┬ ┬ ┬┌┬┐┌─┐┌─┐┌┐ ┌─┐┌─┐┬┌┐┌┌┐┌┌─┐┬─┐ ┌─┐┌─┐┌┬┐"
echo -e " │││││││││ ├─┤ │ ├─┘│ ├┴┐├┤ │ ┬│││││││├┤ ├┬┘ │ │ ││││"
echo -e " └┴┘└┴┘└┴┘o┴ ┴ ┴ ┴ └─┘└─┘└─┘└─┘┴┘└┘┘└┘└─┘┴└─o└─┘└─┘┴ ┴"
echo -e $CYAN
echo -e " __ __ "
echo -e " /\ |_ _ |\/|./ (_ _ _. _ |_ "
echo -e " /--\|_(_)| ||\__ __)(_| ||_)|_ "
echo -e " | "
echo -e $GREEN'AtoMiC .bash_aliases Installer for HTPCs and Home Servers'$ENDCOLOR
echo
echo -e $YELLOW'--->.bash_aliases installation will start soon. Please read the following carefully.'$ENDCOLOR
echo -e '1. The script has been confirmed to work on Ubuntu variants and Ubuntu Server.'
echo -e '2. While several testing runs identified no known issues, '$CYAN'www.htpcBeginner.com'$ENDCOLOR' or the authors cannot be held accountable for any problems that might occur due to the script.'
echo -e '3. By proceeding you authorize this script to make changes required to install .bash_aliases.'
echo -e '4. Best used on a clean system (with no previous .bash_aliases). Any previous .bash_aliases will be backed up.'
echo
read -p 'Type y/Y and press [ENTER] to AGREE and continue with the installation or any other key to exit: '
RESP=${REPLY,,}
if [ "$RESP" != "y" ]
then
echo -e $RED'So you chickened out. May be you will try again later.'$ENDCOLOR
echo
pause 'Press [Enter] key to continue...'
cd $SCRIPTPATH
sudo ./setup.sh
exit 0
fi
echo
echo -n 'Type your username and press [ENTER]. Typically, this is your system login name (IMPORTANT! Ensure correct spelling and case): '
read UNAME
if [ ! -d "/home/$UNAME" ] || [ -z "$UNAME" ]; then
echo -e $RED'Bummer! You may not have entered your username correctly. Exiting now. Please rerun script.'$ENDCOLOR
echo
pause 'Press [Enter] key to continue...'
cd $SCRIPTPATH
sudo ./setup.sh
exit 0
fi
echo
sleep 1
echo -e $YELLOW'--->Checking for previous .bash_aliases...'$ENDCOLOR
mv /home/$UNAME/.bash_aliases /home/$UNAME/.bash_aliases_`date '+%m-%d-%Y_%H-%M'` >/dev/null 2>&1
echo -e 'Any existing .bash_aliases file was moved to '$CYAN'/home/'$UNAME'/.bash_aliases_'`date '+%m-%d-%Y_%H-%M'`$ENDCOLOR
echo
sleep 1
echo -e $YELLOW'--->Checking for .bash_aliases updates...'$ENDCOLOR
git pull >/dev/null 2>&1
echo
sleep 1
echo -e $YELLOW'--->Copying .bash_aliases...'$ENDCOLOR
cd /home/$UNAME
cp $SCRIPTPATH/.bash_aliases . || { echo -e $RED'.bash_aliases not copied.'$ENDCOLOR ; exit 1; }
sudo chown $UNAME: .bash_aliases >/dev/null 2>&1
chmod 755 .bash_aliases >/dev/null 2>&1
echo
sleep 1
echo -e $YELLOW'--->Reloading .bash_aliases...'$ENDCOLOR
. ~/.bashrc
echo
echo -e $GREEN'--->All done. New .bash_aliases now active.'$ENDCOLOR
echo -e 'Please visit '$CYAN' http://www.htpcbeginner.com/create-shortcut-to-commands-using-bashaliases-in-ubuntu/'$ENDCOLOR' to understand how to use .bash_aliases.'
echo -e 'Please read .bash_aliases file for all available shortcut commands.'
echo
echo -e $YELLOW'If this script worked for you, please visit '$CYAN'http://www.htpcBeginner.com'$YELLOW' and like/follow us.'$ENDCOLOR
echo -e $YELLOW'Thank you for using the AtoMiC .bash_aliases Install script from www.htpcBeginner.com.'$ENDCOLOR
echo
pause 'Press [Enter] key to continue...'
cd $SCRIPTPATH
sudo ./setup.sh
exit 0