Netboot Template

From Amahi Wiki
Revision as of 01:25, 10 February 2014 by Bigfoot65 (talk | contribs)
Jump to: navigation, search

INSTALL

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

# Start of Install
cat > html/install.sh << EOF
#!/bin/bash

mkdir -p $NBPATH/$HDA_APP_NAME;
# Copy files to Netboot
cd $WAPATH;
cp ../unpack/live/vmlinuz ../unpack/live/initrd.img ../unpack/live/filesystem.squashfs -d $NBPATH/$HDA_APP_NAME;

# Update PXE 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
if [ -d $NBPATH/menu ]; then
    cp $WAPATH/$HDA_APP_NAME.mnu $NBPATH/menu
    cat $NBPATH/menu/*.mnu >> $NBPATH/pxelinux.cfg/default
  else
    mkdir $NBPATH/menu
    cp $WAPATH/$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 $WAPATH/$HDA_APP_NAME.conf $NBPATH/conf
  else
    mkdir $NBPATH/conf
    cp $WAPATH/$HDA_APP_NAME.conf $NBPATH/conf
fi
cd $WAPATH;
rm -rf ../unpack;
echo "Installation complete.";
# End of Install
EOF
# Start of Uninstall
cat > html/uninstall.sh << EOF
#!/bin/bash
# Remove $WALNAM
rm -rf $NBPATH/$HDA_APP_NAME;
rm -rf $NBPATH/conf/$HDA_APP_NAME.conf;
rm -rf $NBPATH/menu/$HDA_APP_NAME.mnu;
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 "Uninstallation 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 > html/$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 > html/$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

LABEL $HDA_APP_NAME (FAILSAFE)
        MENU LABEL $HDA_APP_NAME (FAILSAFE)
        kernel $HDA_APP_NAME/vmlinuz
        append initrd=$HDA_APP_NAME/initrd.img boot=live union=aufs noswap noprompt vga=normal fetch=tftp://$HDA_IP/$HDA_APP_NAME/filesystem.squashfs live-config

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/1/1b/Gparted_logo.png"></a>
</center>
<h1>GParted Installed!</h1>

<p>The GParted application is the GNOME partition editor for creating, reorganizing, and deleting disk partitions.</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

chmod 755 html/install.sh html/uninstall.sh;

mkdir elevated;
cd elevated 
cp $WAPATH/install.sh .;
sudo ./install.sh;
cd ..;
rm -rf elevated;

UNINSTALL

# App specific variables
export WAPATH=HDA_APP_DIR/html;
# Uninstall
mkdir elevated;
cd elevated;
cp $WAPATH/uninstall.sh .;
sudo ./uninstall.sh;
cd ..;
rm -rf elevated;