-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathINSTALL.sh
More file actions
executable file
·72 lines (56 loc) · 1.41 KB
/
INSTALL.sh
File metadata and controls
executable file
·72 lines (56 loc) · 1.41 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
#! /bin/bash
#--- Author: Muhammad Khubaib Umer
#--- Dated: 11-07-2019
#--- Description: Install Script for system_update.sh
CLR='\033[0;34m'
ENDCLR='\033[0;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
CMD="lupdate"
SCRIPT="$PWD/.system_update.sh"
EX_PATH="$HOME/.system_update.sh"
check_ret() {
if [ $1 -ne 0 ]
then
echo -e "${RED} Install Sequence failed... ${NC}"
exit $1
fi
}
if [[ $EUID -eq 0 ]]
then
echo -e "${RED} Please do not run as root ${NC}"
exit 1
fi
if [[ $1 = "--help" ]] # print usage
then
echo -e "${CLR} Default command is lupdate... You can provide custom command as arg1... ${NC}"
exit 0
fi
if [[ $# -ge 1 ]] # user provided custom command
then
echo -e "${RED} Setting '$1' as command... Press Ctrl-C to abort ${NC}"
sleep 3
CMD=$1
fi
echo -e "${CLR} Setting Ownership... ${NC}"
chown $USER $SCRIPT
check_ret $?
sleep 1
echo -e "${CLR} Setting Execute permission... ${NC}"
chmod a+x $SCRIPT
check_ret $?
sleep 1
echo -e "${CLR} Moving script to: $EX_PATH...${NC}"
cp -f $SCRIPT $EX_PATH
check_ret $?
sleep 1
echo -e "${RED} Adding command: '$CMD' to 'bashrc'... ${NC}"
echo -e "${RED} Press Ctrl-C to abort... ${NC}"
sleep 3
echo "alias $CMD='sudo $EX_PATH' " >> ~/.bashrc
check_ret $?
echo -e "${CLR} Adding 'Ctrl-l' as shortcut for 'lupdate'... ${NC}"
echo "bind '\"\\C-l\"':\"\\\"$CMD \\C-m \\\"\" " >> ~/.bashrc
check_ret $?
echo -e "${CLR} Restart Terminal to reload bashrc... ${NC}"
exit 0