Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Juan Francisco Piñera Ovejero - UO244707
- ALUMNO1=$1
- ALUMNO2=$2
- MICLAVE=$3
- GRUPO="pringaos"
- HOME_DIR="/home/pringaos"
- SHELL1="/bin/bash"
- SHELL2="/bin/sh"
- CIFRADO1=`python -c '\\
- import random
- pos_char= "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- num_car = 8
- salt ="$1$"
- for c in range(num_car):
- salt = salt + pos_char[random.randint(0,len(pos_char)-1)]
- salt += "$"
- print salt'`
- CIFRADO2=`python -c '\\
- import random
- pos_char= "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- num_car = 8
- salt ="$5$"
- for c in range(num_car):
- salt = salt + pos_char[random.randint(0,len(pos_char)-1)]
- salt += "$"
- print salt'`
- # Crea el directorio del grupo si es que no existe
- # para ello debes buscar como comprobar si existe a no un directorio
- # y en caso de existir generar un mensaje que digo auq ya existe
- # y si no crearlo.
- if [ -d $HOME_DIR];
- then
- echo "ya existe el directorio"
- else
- mkdir $HOME_DIR
- fi
- # Crea el grupo al que van a pertenecer los usuarios utilizando la
- # variable GRUPO
- groupadd $GRUPO
- PASSWORD1=`python -c "import crypt;print crypt.crypt('$MICLAVE','$CIFRADO1')"`
- PASSWORD2=`python -c "import crypt;print crypt.crypt('$MICLAVE','$CIFRADO2')"`
- # Creo el usuario1
- useradd -d $HOME_DIR/$ALUMNO1 -m $ALUMNO1 -s $SHELL1 -g $GRUPO -p $PASSWORD1
- # Creo el usuario2
- useradd -d $HOME_DIR/$ALUMNO2 -m $ALUMNO2 -s $SHELL2 -g $GRUPO -p $PASSWORD2
- done
Add Comment
Please, Sign In to add comment