Skip to content

Commit

Permalink
underdog script
Browse files Browse the repository at this point in the history
by mistfire @rizalmartin

will be further edited
  • Loading branch information
wdlkmpx committed Aug 8, 2016
1 parent d5840e3 commit 6541c9a
Showing 1 changed file with 119 additions and 0 deletions.
119 changes: 119 additions & 0 deletions woof-code/rootfs-skeleton/usr/sbin/underdog
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/bin/sh

. /etc/rc.d/PUPSTATE
case $PUPMODE in
5) ERRORMSG="Please create puppy save first" ;;
2) ERRORMSG="Underdog is not applicable on fully installed puppy. It only works on frugal installation." ;;
esac
if [ "$ERRORMSG" ] ; then
echo "$ERRORMSG"
[ $DISPLAY ] && /usr/lib/gtkdialog/box_ok "Underdog" error "$ERRORMSG"
exit 1
fi

function underdog_func() {
if [ "$1" = "start" ]; then
if [ "$TARGET_DRV" != "" ]; then
echo "$TARGET_DRV" > /mnt/home/underdog.lnx
echo "Underdog on $TARGET_DRV enabled"
elif [ "$2" != "" ]; then
echo "$2" > /mnt/home/underdog.lnx
echo "Underdog on $2 enabled"
else
echo "device name not specified"
fi
elif [ "$1" = "stop" ]; then
if [ -f /mnt/home/underdog.lnx ]; then
rm -f /mnt/home/underdog.lnx
echo "Underdog is disabled"
else
echo "Underdog file not found"
fi
else
echo "Usage: underdog [start|stop] <drive_name (e.g sda1)>"
fi
}

if [ $1 ] || [ ! $DISPLAY ] ; then
underdog_func $@
exit
fi

####################################################
# GUI
####################################################

drvitem=""
status=""
drvhost=""

if [ -f /mnt/home/underdog.lnx ]; then
drvhost=$(cat /mnt/home/underdog.lnx)
status="ENABLED"
start_button="false"
stop_button="true"
combobox="false"
else
drvhost="NONE"
status="DISABLED"
start_button="true"
stop_button="false"
combobox="true"
fi

XHOME=$(mount | cut -f 1,3 -d ' ' | grep "/mnt/dev_save" | cut -f 1 -d ' ')
for drv in `probepart | cut -f 1 -d '|' | grep -E "/(s|h)d[a-z][0-9]" | grep -v "${XHOME}" | cut -f 3 -d "/"`
do drvitem="$drvitem<item>$drv</item>"
done

WINDOW_MSG="$(/usr/lib/gtkdialog/xml_info 0 puppy.svg 48 "This is a tool to allow puppy to use partition of other linux distro.")"
export UNDERDOG_DIALOG="<window title=\"Underdog Linux\" image-name=\"/usr/share/pixmaps/puppy/preferences.svg\">
<vbox>
$WINDOW_MSG
<text use-markup=\"true\"><label>\"WARNING: For advanced users only\"</label></text>
<frame>
<vbox>
<text use-markup=\"true\"><label>\"Status: $status\"</label></text>
<text use-markup=\"true\"><label>\"Partition in used: $drvhost\"</label></text>
</vbox>
</frame>
<hbox>
<text><label>Partition Name:</label></text>
<combobox>
<variable>TARGET_DRV</variable>
<sensitive>\"$combobox\"</sensitive>
$drvitem
</combobox>
</hbox>
<hbox>
<button>
<label>Start Underdog</label>
<sensitive>\"$start_button\"</sensitive>
$(/usr/lib/gtkdialog/xml_button-icon dialog-complete.svg)
<action>$0 start</action>
<action>/usr/lib/gtkdialog/box_ok \"Underdog\" info \"Underdog is enabled. Please restart Puppy to apply changes\"</action>
<action type=\"exit\">exit</action>
</button>
<button>
<label>Stop Underdog</label>
<sensitive>\"$stop_button\"</sensitive>
$(/usr/lib/gtkdialog/xml_button-icon dialog-error.svg)
<action>$0 stop</action>
<action>/usr/lib/gtkdialog/box_ok \"Underdog\" info \"Underdog is disabled. Please restart Puppy to apply changes\"</action>
<action type=\"exit\">exit</action>
</button>
<text><label>\" \"</label></text>
<text><label>\" \"</label></text>
<button>
$(/usr/lib/gtkdialog/xml_button-icon quit.svg)
<label>Quit</label>
<action type=\"exit\">Cancel</action>
</button>
</hbox>
</vbox>
</window>"

. /usr/lib/gtkdialog/xml_info gtk #build bg_pixmap for gtk-theme
gtkdialog --center --program=UNDERDOG_DIALOG

### END ###

0 comments on commit 6541c9a

Please sign in to comment.