?>/script>'; } ?> Permisos root en bootinst.sh Widgets Magazine

Autor Tema: Permisos root en bootinst.sh  (Leído 7490 veces)

0 Usuarios y 1 Visitante están viendo este tema.

vk496

  • Visitante
Permisos root en bootinst.sh
« en: 20-07-2015, 13:37 (Lunes) »
No es la priemra vez que uso el bootinst.sh sin root (sin querer) y me toca reiniciar el PC para instalarlo de nuevo.

Código: [Seleccionar]
#!/bin/bash

if [[ $(id -u) -ne 0 ]]; then
    echo "Not running as root"
    exit
fi

chmod 0777 /tmp &> /dev/null
set -e
TARGET=""
MBR=""

# Find out which partition or disk are we using
MYMNT=$(cd -P $(dirname $0) ; pwd)
while [ "$MYMNT" != "" -a "$MYMNT" != "." -a "$MYMNT" != "/" ]; do
   TARGET=$(egrep "[^[:space:]]+[[:space:]]+$MYMNT[[:space:]]+" /proc/mounts | cut -d " " -f 1)
   if [ "$TARGET" != "" ]; then break; fi
   MYMNT=$(dirname "$MYMNT")
done

if [ "$TARGET" = "" ]; then
   echo "Can't find device to install to."
   echo "Make sure you run this script from a mounted device."
   exit 1
fi

if [ "$(cat /proc/mounts | grep "^$TARGET" | grep noexec)" ]; then
   echo "The disk $TARGET is mounted with noexec parameter, trying to remount..."
   mount -o remount,exec "$TARGET"
   sleep 3
fi

MBR=$(echo "$TARGET" | sed -r "s/[0-9]+\$//g")
NUM=${TARGET:${#MBR}}
TMP="/tmp/$$"
mkdir -p "$TMP"
cd "$MYMNT"
cp -f ./boot/syslinux/lilo "$TMP"
cp -f ./boot/syslinux/syslinux "$TMP"
chmod +x "$TMP"/*

clear
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo "                        Welcome to Wifislax boot installer                         "
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
echo
echo "This installer will setup disk $TARGET to boot only Wifislax."
if [ "$MBR" != "$TARGET" ]; then
   echo
   echo "Warning! Master boot record (MBR) of $MBR will be overwritten."
   echo "If you use $MBR to boot any existing operating system, it will not work"
   echo "anymore. Only Wifislax will boot from this device. Be careful!"
fi
echo
echo "Press any key to continue, or Ctrl+C to abort..."
read junk
clear

echo "Flushing filesystem buffers, this may take a while..."
sync

# setup MBR if the device is not in superfloppy format
if [ "$MBR" != "$TARGET" ]; then
   echo "Setting up MBR on $MBR..."
   "$TMP"/lilo -S /dev/null -M $MBR ext # this must be here to support -A for extended partitions
   echo "Activating partition $TARGET..."
   "$TMP"/lilo -S /dev/null -A $MBR $NUM
   echo "Updating MBR on $MBR..." # this must be here because LILO mbr is bad. mbr.bin is from syslinux
   cat ./boot/syslinux/mbr.bin > $MBR
fi

echo "Setting up boot record for $TARGET..."
chmod +t /tmp
"$TMP"/syslinux -U -d boot/syslinux $TARGET
rm -rf "$TMP"
echo "Disk $TARGET should be bootable now. Installation finished."

echo
echo "Read the information above and then press any key to exit..."
read junk
 

Solo son las 4 priemras lineas de codigo... Pero dejo todo por si acaso

Salu2

Desconectado USUARIONUEVO

  • Moderador
  • *
  • Mensajes: 15985
Re: Permisos root en bootinst.sh
« Respuesta #1 en: 21-07-2015, 00:42 (Martes) »
no entiendo lo que quieres decir ...

cuando tengo problemas de permiso   (sucede sobretodo cuando el usb ha sido montado en /run )

basta con


sh /bootisnt.sh

y a volar.

Desconectado geminis_demon

  • Colaborador
  • *
  • Mensajes: 2378
  • Prácticas precisas precisan práctica
Re: Permisos root en bootinst.sh
« Respuesta #2 en: 21-07-2015, 01:51 (Martes) »
¿Usas Wifislax con un usuario sin privilegios? Pues habrás tenido que adaptar todo el sistema porque sin ser root no funciona casi nada...


Desconectado USUARIONUEVO

  • Moderador
  • *
  • Mensajes: 15985
Re: Permisos root en bootinst.sh
« Respuesta #3 en: 21-07-2015, 02:52 (Martes) »
¿Usas Wifislax con un usuario sin privilegios? Pues habrás tenido que adaptar todo el sistema porque sin ser root no funciona casi nada...



me imagino que lo hara desde otro S.O , algun debian  , y entonces no podra ejecutarlo.

aunque como digo ,a mi siempre me ha funcionado con sh delante.

vk496

  • Visitante
Re: Re: Permisos root en bootinst.sh
« Respuesta #4 en: 21-07-2015, 09:46 (Martes) »


¿Usas Wifislax con un usuario sin privilegios? Pues habrás tenido que adaptar todo el sistema porque sin ser root no funciona casi nada...



me imagino que lo hara desde otro S.O , algun debian  , y entonces no podra ejecutarlo.

Claro, es eso. Desde otro SO, cuando lo ejecutas sin ser root el instalador sigue como si nada... Poniendo ese condicional delante se evitará dejarlo a medias.

Es una tontería, pero creo que vendrá bien para los despistados... :D

Salu2

Desconectado geminis_demon

  • Colaborador
  • *
  • Mensajes: 2378
  • Prácticas precisas precisan práctica
Re: Permisos root en bootinst.sh
« Respuesta #5 en: 21-07-2015, 18:41 (Martes) »
Ahh ok, ahora entiendo.

Pues si, no es mala idea.

Desconectado USUARIONUEVO

  • Moderador
  • *
  • Mensajes: 15985
Re: Permisos root en bootinst.sh
« Respuesta #6 en: 22-07-2015, 22:12 (Miércoles) »
sugerencia recogida/integrada.

 ;)