-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall.sh
More file actions
73 lines (59 loc) · 2.25 KB
/
install.sh
File metadata and controls
73 lines (59 loc) · 2.25 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
71
72
73
#!/bin/bash
# Place username here
USER=
# Where will reverseme be located at?
# Please use absolute path
# By default, reverseme is installed in the home directory of the specificed user
# It is better to use absolute path because this script will be run by root instead of the local user
DIRECTORY=/home/${USER}/reverseme
# This variable holds the file location for your .bash_aliases
# Use absolute path because this script will be run by root instead of the local user
ALIAS_FILE=/home/${USER}/.bash_aliases
# Default file that bash uses before starting the interactive shell
# By default it is .bashrc
# However, you can change it to any one you like.
# Some newer Ubuntu systems use .profile. If you wish, I have built one for .profile below. Just edit this one out.
SOURCE_FILE=/home/${USER}/.bashrc
#Source_FILE=/home/${USER}/.profile
# Check if user is root
if [[ $EUID -ne 0 ]] ; then
echo "Please run me as root!"
exit 1
fi
# Check if user variable is blank
if [ -z ${USER} ] ; then
echo "User varialbe was left blank. Please add a user!"
exit 1
fi
# Check if directory variable is blank
if [ -z ${DIRECTORY} ] ; then
echo "Directory variable was left blank. Please add an absolute path on where reverseme will be installed!."
exit 1
fi
# Make sure directory variable has /reverseme on the end, with no leading "/"
if [[ ${DIRECTORY} =~ /reverseme/$ ]] ; then
DIRECTORY=$(echo ${DIRECTORY} | sed 's/\/*$//g')
fi
# Make sure directory exists
if [ ! -d ${DIR} ] ; then
echo "This directory was not found!"
echo "Are you sure the correct directory is being used?"
exit 1
# if directory exists proceed
elif [ -d ${DIR} ] ; then
if [ ! -f ${ALIAS_FILE} ] ; then
echo "Alias file: ${ALIAS_FILE} not found. Creating now..."
touch ${ALIAS_FILE}
echo "File created!"
fi
echo -e "\n# reverseme" >> ${ALIAS_FILE}
echo -e "alias reverseme='/usr/bin/bash ${DIRECTORY}/main.sh'" >> ${ALIAS_FILE}
echo -e "\nsource ${DIRECTORY}/reverseme_completion.bash" >> ${SOURCE_FILE}
fi
# source shells.sh script into main.sh for user
sed -i "4i\\. ${DIRECTORY}/shells.sh" main.sh
# If user is using apt package manager, check if xclip is installed.
# If not attempt to install.
echo "Checking if xclip is installed..."
xclip -h > /dev/null 2>&1 \
|| apt install xclip -y ; exit 0