Difference between revisions of "Netboot Template"

From Amahi Wiki
Jump to: navigation, search
(Created page with "<u>'''INSTALL'''</u> # App specific variables export WASNAM='pmagic'; export WALNAM='Parted Magic'; export WAPATH='/var/hda/web-apps/pmagic/html'; # Constant variables--DO NOT CH...")
 
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<u>'''INSTALL'''</u>
 
<u>'''INSTALL'''</u>
 +
<pre>#Temp download/extract files
 +
mkdir -p files;
 +
echo Extracting files;
 +
unzip -q source-file -d files;
 +
 +
mkdir -p elevated;
 +
cd elevated;
 +
 
# App specific variables
 
# App specific variables
export WASNAM='pmagic';
 
export WALNAM='Parted Magic';
 
export WAPATH='/var/hda/web-apps/pmagic/html';
 
 
# Constant variables--DO NOT CHANGE
 
# Constant variables--DO NOT CHANGE
export NBPATH='/usr/share/amahi-netboot/tftp';
+
export NBPATH='/var/lib/tftpboot';
export HDAIP=`ifconfig eth0 | grep "inet addr" | awk '{ print $2 }' | awk 'BEGIN { FS=":" } { print $2 }'`;
 
  
# Start of $WALNAM Install
+
# Start of Install
cat > html/install-$WASNAM.sh << EOF
+
cat > ../install.sh << EOF
 
#!/bin/bash
 
#!/bin/bash
mkdir -p $NBPATH/$WASNAM;
+
echo Copying files;
# Copy $WALNAM files to Netboot
+
mkdir -p $NBPATH/$HDA_APP_NAME;
cp $WAPATH/$WASNAM/* -d $NBPATH/$WASNAM;
+
# Copy files to Netboot
 +
cp ../files/live/vmlinuz ../files/live/initrd.img ../files/live/filesystem.squashfs -d $NBPATH/$HDA_APP_NAME;
 +
 
 
# Update PXE Menu
 
# Update PXE Menu
 +
echo Backing up menu;
 
if [ -f $NBPATH/pxelinux.cfg/default.bu ]; then
 
if [ -f $NBPATH/pxelinux.cfg/default.bu ]; then
 
     cp $NBPATH/pxelinux.cfg/default.bu $NBPATH/pxelinux.cfg/default
 
     cp $NBPATH/pxelinux.cfg/default.bu $NBPATH/pxelinux.cfg/default
Line 21: Line 28:
 
fi
 
fi
 
# Append app menu to default
 
# Append app menu to default
 +
echo Updating menu;
 
if [ -d $NBPATH/menu ]; then
 
if [ -d $NBPATH/menu ]; then
     cp $WAPATH/$WASNAM.mnu $NBPATH/menu
+
     cp ../$HDA_APP_NAME.mnu $NBPATH/menu
 
     cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
 
     cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
 
   else
 
   else
 
     mkdir $NBPATH/menu
 
     mkdir $NBPATH/menu
     cp $WAPATH/$WASNAM.mnu $NBPATH/menu
+
     cp ../$HDA_APP_NAME.mnu $NBPATH/menu
 
     cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
 
     cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
 
fi
 
fi
 
# Copy submenu (if needed) to conf
 
# Copy submenu (if needed) to conf
 
if [ -d $NBPATH/conf ]; then
 
if [ -d $NBPATH/conf ]; then
     cp $WAPATH/$WASNAM.conf $NBPATH/conf
+
     cp ../$HDA_APP_NAME.conf $NBPATH/conf
 
   else
 
   else
 
     mkdir $NBPATH/conf
 
     mkdir $NBPATH/conf
     cp $WAPATH/$WASNAM.conf $NBPATH/conf
+
     cp ../$HDA_APP_NAME.conf $NBPATH/conf
 
fi
 
fi
echo "Installation complete.";
+
echo "Removing source files";
# End of $WALNAM Install
+
rm -rf ../files;
 +
echo "Install complete";
 +
# End of Install
 
EOF
 
EOF
# Start of $WASNAM Uninstall
+
# Start of Uninstall
cat > html/uninstall-$WASNAM.sh << EOF
+
cat > ../uninstall.sh << EOF
 
#!/bin/bash
 
#!/bin/bash
# Remove $WALNAM
+
echo Removing files;
rm -rf $NBPATH/$WASNAM;
+
rm -rf ../files;
rm -rf $NBPATH/conf/$WASNAM.conf;
+
rm -rf $NBPATH/$HDA_APP_NAME;
rm -rf $NBPATH/menu/$WASNAM.mnu;
+
rm -rf $NBPATH/conf/$HDA_APP_NAME.conf;
 +
rm -rf $NBPATH/menu/$HDA_APP_NAME.mnu;
 +
echo Restoring menu backup;
 
cp $NBPATH/pxelinux.cfg/default.bu $NBPATH/pxelinux.cfg/default;
 
cp $NBPATH/pxelinux.cfg/default.bu $NBPATH/pxelinux.cfg/default;
 +
if [ -f $NBPATH/menu/*.mnu ]; then
 
cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
 
cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
echo "Uninstallation complete.";
+
fi
# End of $WALNAM Uninstall
+
echo "Uninstall complete";
 +
# End of Uninstall
 
EOF
 
EOF
 
# This needs to be changed to match the app.  This can be a single menu or link to a sub menu
 
# This needs to be changed to match the app.  This can be a single menu or link to a sub menu
cat > html/$WASNAM.mnu << EOF
+
cat > ../$HDA_APP_NAME.mnu << EOF
LABEL Parted Magic
+
LABEL $HDA_APP_NAME
       MENU LABEL Parted Magic
+
       MENU LABEL $HDA_APP_NAME
 
       kernel menu.c32
 
       kernel menu.c32
       append conf/pmagic.conf
+
       append conf/$HDA_APP_NAME.conf
 
EOF
 
EOF
 
# This is specific to the app and may not be needed.  It generates a sub menu
 
# This is specific to the app and may not be needed.  It generates a sub menu
cat > html/$WASNAM.conf << EOF
+
cat > ../$HDA_APP_NAME.conf << EOF
MENU TITLE Parted Magic
+
MENU TITLE $HDA_APP_NAME
LABEL Parted Magic
+
LABEL $HDA_APP_NAME
    MENU LABEL Parted Magic
+
        MENU LABEL $HDA_APP_NAME
kernel pmagic/bzImage
+
        kernel $HDA_APP_NAME/vmlinuz
append initrd=pmagic/initramfs load_ramdisk=1 prompt_ramdisk=0 rw sleep=10
+
        append initrd=$HDA_APP_NAME/initrd.img boot=live union=aufs noswap noprompt vga=788 fetch=tftp://$HDA_IP/$HDA_APP_NAME/filesystem.squashfs live-config
 
LABEL Parted Magic (FAILSAFE)
 
    MENU LABEL Parted Magic (FAILSAFE)
 
kernel pmagic/bzImage
 
append initrd=pmagic/initramfs load_ramdisk=1 prompt_ramdisk=0 rw sleep=10 livemedia
 
EOF
 
 
 
cat > html/index.html << EOF
 
<html>
 
<head>
 
<title>      </title>
 
<style type="text/css">
 
<!--
 
h1 {text-align:center;
 
font-family:Arial, Helvetica, Sans-Serif;
 
}
 
 
 
p {text-indent:20px;
 
}
 
-->
 
</style>
 
</head>
 
<body bgcolor = "#ffffcc" text = "#000000">
 
<center>
 
<img src="http://wiki.amahi.org/images/6/60/Partedmagic-logo.png"></a>
 
</center>
 
<h1>Parted Magic Installed!</h1>
 
 
 
<p>The Parted Magic OS employs core programs of GParted and Parted to handle partitioning tasks with ease, while featuring other useful <a href="/programs.html" mce_href="/programs.html" target="_blank">programs</a> (e.g. Clonezilla, Partimage, TestDisk, Truecrypt, G4L, SuperGrubDisk, ddrescue, etc...) and an excellent set of <a href="/documentation.html" mce_href="/documentation.html" target="_blank">documentation</a> to benefit the user. An extensive collection of file system tools are also included, as Parted Magic supports the following: ext2, ext3, ext4, fat16, fat32, hfs, hfs+, jfs, linux-swap, ntfs, reiserfs, reiser4, and xfs.</p>
 
 
 
<p><b>NOTE:</b>  This application is a PXE network bootable OS which cannot be accessed via a web browser.  Uncheck <b>List in dashboard</b> option to remove link from dashboard.</p>
 
</body>
 
</html>
 
 
EOF
 
EOF
  
chmod 755 html/install-$WASNAM.sh html/uninstall-$WASNAM.sh;
+
chmod 755 ../install.sh ../uninstall.sh;
 
+
cp ../install.sh .;
mkdir elevated;
+
sudo ./install.sh;
cd elevated
 
cp $WAPATH/install-$WASNAM.sh .;
 
sudo ./install-$WASNAM.sh;
 
 
cd ..;
 
cd ..;
 
rm -rf elevated;
 
rm -rf elevated;
 +
 +
rm -rf *.zip;</pre>
  
 
<u>'''UNINSTALL'''</u>
 
<u>'''UNINSTALL'''</u>
# App specific variables
+
<pre># Uninstall
export WASNAM='pmagic';
+
mkdir -p elevated;
export WAPATH='/var/hda/web-apps/pmagic/html';
 
# Uninstall $WASNAM
 
mkdir elevated;
 
 
cd elevated;
 
cd elevated;
cp $WAPATH/uninstall-$WASNAM.sh .;
+
cp ../uninstall.sh .;
sudo ./uninstall-$WASNAM.sh;
+
sudo ./uninstall.sh;
 
cd ..;
 
cd ..;
rm -rf elevated;
+
rm -rf elevated;</pre>

Latest revision as of 04:02, 29 March 2015

INSTALL

#Temp download/extract files
mkdir -p files;
echo Extracting files;
unzip -q source-file -d files;

mkdir -p elevated;
cd elevated;

# App specific variables
# Constant variables--DO NOT CHANGE
export NBPATH='/var/lib/tftpboot';

# Start of Install
cat > ../install.sh << EOF
#!/bin/bash
echo Copying files;
mkdir -p $NBPATH/$HDA_APP_NAME;
# Copy files to Netboot
cp ../files/live/vmlinuz ../files/live/initrd.img ../files/live/filesystem.squashfs -d $NBPATH/$HDA_APP_NAME;

# Update PXE Menu
echo Backing up menu;
if [ -f $NBPATH/pxelinux.cfg/default.bu ]; then
     cp $NBPATH/pxelinux.cfg/default.bu $NBPATH/pxelinux.cfg/default
  else
     cp $NBPATH/pxelinux.cfg/default $NBPATH/pxelinux.cfg/default.bu
fi
# Append app menu to default
echo Updating menu;
if [ -d $NBPATH/menu ]; then
    cp ../$HDA_APP_NAME.mnu $NBPATH/menu
    cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
  else
    mkdir $NBPATH/menu
    cp ../$HDA_APP_NAME.mnu $NBPATH/menu
    cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
fi
# Copy submenu (if needed) to conf
if [ -d $NBPATH/conf ]; then
    cp ../$HDA_APP_NAME.conf $NBPATH/conf
  else
    mkdir $NBPATH/conf
    cp ../$HDA_APP_NAME.conf $NBPATH/conf
fi
echo "Removing source files";
rm -rf ../files;
echo "Install complete";
# End of Install
EOF
# Start of Uninstall
cat > ../uninstall.sh << EOF
#!/bin/bash
echo Removing files;
rm -rf ../files;
rm -rf $NBPATH/$HDA_APP_NAME;
rm -rf $NBPATH/conf/$HDA_APP_NAME.conf;
rm -rf $NBPATH/menu/$HDA_APP_NAME.mnu;
echo Restoring menu backup;
cp $NBPATH/pxelinux.cfg/default.bu $NBPATH/pxelinux.cfg/default;
if [ -f $NBPATH/menu/*.mnu ]; then
cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
fi
echo "Uninstall complete";
# End of Uninstall
EOF
# This needs to be changed to match the app.  This can be a single menu or link to a sub menu
cat > ../$HDA_APP_NAME.mnu << EOF
LABEL $HDA_APP_NAME
      MENU LABEL $HDA_APP_NAME
      kernel menu.c32
      append conf/$HDA_APP_NAME.conf
EOF
# This is specific to the app and may not be needed.  It generates a sub menu
cat > ../$HDA_APP_NAME.conf << EOF
MENU TITLE $HDA_APP_NAME
LABEL $HDA_APP_NAME
        MENU LABEL $HDA_APP_NAME
        kernel $HDA_APP_NAME/vmlinuz
        append initrd=$HDA_APP_NAME/initrd.img boot=live union=aufs noswap noprompt vga=788 fetch=tftp://$HDA_IP/$HDA_APP_NAME/filesystem.squashfs live-config
EOF

chmod 755 ../install.sh ../uninstall.sh;
cp ../install.sh .;
sudo ./install.sh;
cd ..;
rm -rf elevated;

rm -rf *.zip;

UNINSTALL

# Uninstall
mkdir -p elevated;
cd elevated;
cp ../uninstall.sh .;
sudo ./uninstall.sh;
cd ..;
rm -rf elevated;