-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·97 lines (84 loc) · 3.78 KB
/
install.sh
File metadata and controls
executable file
·97 lines (84 loc) · 3.78 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
if [ "`whoami`" != "root" ]; then
echo "Has de ser root o ejecutarlo como root para poder seguir"
exit
fi
DIRNAME="$(dirname $0)"
INSTALLATION_DIR="/opt"
INSTALLATION_PROJECT="$INSTALLATION_DIR/OSCP"
EXECUTABLE_DIR="$INSTALLATION_PROJECT/notas.py"
RESTORE='\033[0m'
RED='\033[00;31m'
GREEN='\033[00;32m'
LBLUE='\033[01;34m'
clear
echo -e "$GREEN░▀█▀░█▀█░█▀▀░▀█▀░█▀█░█░░░█▀█░█▀▀░▀█▀░█▀█░█▀█░░░█▀█░█▀▀░█▀▀░█▀█$RESTORE"
echo -e "$GREEN░░█░░█░█░▀▀█░░█░░█▀█░█░░░█▀█░█░░░░█░░█░█░█░█░░░█░█░▀▀█░█░░░█▀▀$RESTORE"
echo -e "$GREEN░▀▀▀░▀░▀░▀▀▀░░▀░░▀░▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀░▀░░░▀▀▀░▀▀▀░▀▀▀░▀░░$RESTORE"
echo -e "\n$GREEN[+]$RESTORE Instalando aplicacion en" $INSTALLATION_DIR
# Comprueba que estan instaladas las dependencias de python necesarias
echo -e "$GREEN[+]$RESTORE Comprobando dependencias de python"
python -c "import termcolor" 2> /dev/null
if [ $? -ne 0 ]; then
echo -e "$LBLUE[!]$RESTORE Instalando libreria termcolor"
pip install termcolor
fi
python -c "import git" 2> /dev/null
if [ $? -ne 0 ]; then
echo -e "$LBLUE[!]$RESTORE Instalando libreria git"
pip install gitpython
fi
python -c "import shutil" 2> /dev/null
if [ $? -ne 0 ]; then
echo -e "$LBLUE[!]$RESTORE Instalando libreria shutil"
pip install shutilwhich
fi
echo -e "$GREEN[+]$RESTORE Librerias de python comprobadas e instaladas"
# Comprueba si existe el directorio de instalacion
if [ ! -d $INSTALLATION_PROJECT ]; then
mkdir $INSTALLATION_PROJECT
echo -e "$GREEN[+]$RESTORE Directorio" $INSTALLATION_PROJECT" creado correctamente"
# Copia ficheros y directorios al directorio de instalacion
find . -maxdepth 1 -type f -exec cp {} $INSTALLATION_PROJECT \;
find . -maxdepth 1 -type d -not -path '*/\.*' -exec cp -r {} $INSTALLATION_PROJECT \;
echo -e "$GREEN[+]$RESTORE Ficheros copiados a $INSTALLATION_PROJECT correctamente"
else
echo -e "$RED[-]$RESTORE El directorio $INSTALLATION_PROJECT ya existe\n"
exit
fi
# Crea un alias para ejecutarlo desde cualquier sitio de la terminal
echo -e "$GREEN[+]$RESTORE Creando alias de la aplicacion\n"
if [ -f ~/.aliases ]; then
# Comprueba si existe ya un alias creado para este programa
existe=`grep "notas.py" ~/.aliases`
if [ $? -ne 0 ]; then
echo 'alias notas="python '$EXECUTABLE_DIR'"' >> ~/.aliases
fi
elif [ -f ~/.bash_aliases ]; then
# Comprueba si existe ya un alias creado para este programa
existe=`grep "notas.py" ~/.bash_aliases`
if [ $? -ne 0 ]; then
echo 'alias notas="python '$EXECUTABLE_DIR'"' >> ~/.bash_aliases
fi
elif [ -f ~/.bashrc ]; then
# Comprueba si existe ya un alias creado para este programa
existe=`grep "notas.py" ~/.bashrc`
if [ $? -ne 0 ]; then
echo 'alias notas="python '$EXECUTABLE_DIR'"' >> ~/.bashrc
fi
fi
# Si se va a usar el programa con un usuario que no sea root se han de cambiar
# los permisos de la carpeta donde se va a instalar
read -e -p "¿Vas a usar la aplicacion con un usuario sin privilegios? [s/n]: " opt
if [ "$opt" == "s" ]; then
read -e -p "Usuario con el que se va a ejecutar: " username
check_user=`cat /etc/passwd | cut -d':' -f1 | grep $username`
if [ "$check_user" == "$username" ]; then
chown -R $username:$username $INSTALLATION_PROJECT
echo -e "$GREEN[+]$RESTORE Permisos cambiados correctamente"
else
echo -e "$RED[-]$RESTORE El usuario introducido no existe."
fi
fi
echo -e "\n$GREEN[*]$RESTORE Instalacion completa creada en" $INSTALLATION_PROJECT
echo -e "\n$LBLUE[!]$RESTORE Para ejecutar la aplicacion abre otra terminal y escribe notas\n"