close
Warning:
Failed to sync with repository "ogBrowser-Git": (1366, "Incorrect string value: '\\xF0\\x9F\\x93\\xA6 I...' for column 'message' at row 1"); repository information may be out of date. Look in the Trac log for more information including mitigation strategies.
918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
| Line | |
|---|
| 1 | #!/bin/bash |
|---|
| 2 | # setsmbpass: cambia la contraseña del usuario del cliente para acceder a los |
|---|
| 3 | # servicios Samba. |
|---|
| 4 | # Nota: se modifica el Initrd del cliente y se cambia la clave en el servidor. |
|---|
| 5 | # Nota: no se modifica el usuario de acceso (usuario "opengnsys"). |
|---|
| 6 | # Uso: setsmbpass |
|---|
| 7 | # Autor: Ramon Gomez - Univ. Sevilla, julio 2011 |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | # Variables. |
|---|
| 11 | PROG=$(basename $0) |
|---|
| 12 | OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"} |
|---|
| 13 | SAMBAUSER="opengnsys" # Usuario por defecto. |
|---|
| 14 | CLIENTINITRD=$OPENGNSYS/tftpboot/ogclient/oginitrd.img |
|---|
| 15 | TMPDIR=/tmp/ogclient$$ |
|---|
| 16 | |
|---|
| 17 | # Control básico de errores. |
|---|
| 18 | if [ $# != 0 ]; then |
|---|
| 19 | echo "$PROG: Error de ejecución" >&2 |
|---|
| 20 | echo "Formato: $PROG" |
|---|
| 21 | exit 1 |
|---|
| 22 | fi |
|---|
| 23 | if [ "$USER" != "root" ]; then |
|---|
| 24 | echo "$PROG: Error: solo ejecutable por root" >&2 |
|---|
| 25 | exit 1 |
|---|
| 26 | fi |
|---|
| 27 | |
|---|
| 28 | # Crear clave para usuario de acceso a los recursos. |
|---|
| 29 | if [ -r $CLIENTINITRD ]; then |
|---|
| 30 | stty -echo 2>/dev/null |
|---|
| 31 | echo -n "Clave del usuario Samba: " |
|---|
| 32 | read SAMBAPASS |
|---|
| 33 | echo |
|---|
| 34 | echo -n "Confirmar clave: " |
|---|
| 35 | read SAMBAPASS2 |
|---|
| 36 | echo |
|---|
| 37 | stty echo 2>/dev/null |
|---|
| 38 | if [ "$SAMBAPASS" != "$SAMBAPASS2" ]; then |
|---|
| 39 | echo "$PROG: Error: las claves no coinciden" >&2 |
|---|
| 40 | exit 2 |
|---|
| 41 | fi |
|---|
| 42 | # Editar la parte de acceso del cliente: |
|---|
| 43 | # descomprimir Initrd, sustituir clave y recomprimir Initrd). |
|---|
| 44 | mkdir -p $TMPDIR |
|---|
| 45 | cd $TMPDIR |
|---|
| 46 | gzip -dc $CLIENTINITRD | cpio -im |
|---|
| 47 | if [ -f scripts/ogfunctions ]; then |
|---|
| 48 | sed -i "s/OPTIONS=\(.*\)user=\w*\(.*\)pass=\w*\(.*\)/OPTIONS=\1user=$SAMBAUSER\2pass=$SAMBAPASS\3/" scripts/ogfunctions |
|---|
| 49 | find . | cpio -H newc -oa | gzip -9c > $CLIENTINITRD |
|---|
| 50 | else |
|---|
| 51 | echo "$PROG: Aviso: no se ha modificado la clave del cliente." |
|---|
| 52 | fi |
|---|
| 53 | rm -fr $TMPDIR |
|---|
| 54 | else |
|---|
| 55 | SAMBAPASS="og" # Clave por defecto. |
|---|
| 56 | echo "$PROG: Aviso: no se ha modificado la clave del cliente." |
|---|
| 57 | fi |
|---|
| 58 | echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | smbpasswd -a -s $SAMBAUSER |
|---|
| 59 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.