Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions instalar
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@

#A copy of the GNU General Public License is available as /usr/share/common-licenses/GPL in the Debian GNU/Linux distribution or on the World Wide Web at the GNU website You can also obtain it by writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA

REMOTE_TYPE=${REMOTE_TYPE:-'NFS'} # NFS, CIFS
SERVER=10.10.20.3
HD='/dev/sda'
HD_SWAP=4096
HD_ROOT=20480
LOCAL_MP='/tmp/pxe'
REMOTE_MP='/pxe'
IMAGE_DIR="$LOCAL_MP/img"
NFSMOUNT=`/etc/init.d/nfsmount status | awk -F: '{print $2}' | sed 's/ //g'`

START_TIME=0
END_TIME=0

is_nfsmount_started() {
test $(/etc/init.d/nfsmount status | awk -F: '{print $2}' | sed 's/ //g') = 'started'
}

function pause(){
read -p "$*"
}
Expand Down Expand Up @@ -74,13 +79,21 @@ function img_install(){
echo "* Instalación de la imagen *"
echo "Iniciando instalación de imagen"

if [ $NFSMOUNT != 'started' ]; then
if [ "$REMOTE_TYPE" = 'NFS' ] && ! is_nfsmount_started; then
echo "Servicio NFS desactivado, activando..."
/etc/init.d/nfsmount start &> /dev/null
fi

mkdir $LOCAL_MP
mount -o nolock $SERVER:$REMOTE_MP $LOCAL_MP &> /dev/null
case "$REMOTE_TYPE" in
(NFS) mount -t nfs -o nolock "$SERVER:$REMOTE_MP" "$LOCAL_MP" &> /dev/null \
&& REMOTE_MOUNTED=yes
;;
(CIFS) mount -t cifs -o ro,guest "//$SERVER$REMOTE_MP" "$LOCAL_MP" &> /dev/null \
&& REMOTE_MOUNTED=yes
;;
(*) REMOTE_MOUNTED=no # local
esac
cd $IMAGE_DIR
IMAGES=($(ls -f ./*.fsa))
cd - &> /dev/null
Expand All @@ -106,9 +119,11 @@ La operación puede durar aproximadamente 5 minutos."

fsarchiver restfs $IMAGE_DIR/${IMAGES[$SELECTED]} id=0,dest="$HD"1 &> /dev/null
fsarchiver restfs $IMAGE_DIR/${IMAGES[$SELECTED]} id=1,dest="$HD"3 &> /dev/null
umount $IMAGE_DIR &> /dev/null
if [ $REMOTE_MOUNTED = yes ]; then
umount "$LOCAL_MP" &> /dev/null
fi

if [ $NFSMOUNT = 'started' ]; then
if [ "$REMOTE_TYPE" = 'NFS' ] && is_nfsmount_started; then
echo "Servicio NFS activado, desactivando..."
/etc/init.d/nfsmount start &> /dev/null
fi
Expand Down