#!/bin/sh # # winswap Enable swap space at Windows swap file # # chkconfig: 345 90 90 # # description: Find Windows swap files and font files # and enble them for Linux system # # 13 Jul 2009 Masaki Shinomiya # on puppy linux only because of probepart # 15 Jul 2009 support Windows 2000/XP #WINSYS=sda1 #WINSYS=hda1 MOUNTOPT="" SWAPFILENAMES="pagefile.sys WIN386.SWP WINDOWS/WIN386.SWP" WINFONTSDIRS="/WINDOWS/Fonts /WINNT/Fonts /WINDOWS/FONTS" LINFONTSDIR=/usr/share/fonts/default PATH=/sbin/:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin # See how we were called. case "$1" in stop) rm -fR $LINFONTSDIR/winfonts ;; off) SWAPS=$(cat /proc/swaps | grep ^/ | grep /$SWAPFILENAME | cut -d' ' -f1) [ "$SWAPS" = "" ] && exit swapoff $SWAPS rm -fR $LINFONTSDIR/winfonts ;; status) cat /proc/swaps ls -l $LINFONTSDIR/winfonts 2>/dev/null ;; *) #mount WINSYS if specified if [ "$WINSYS" ]; then if ! mount | grep -q "^/dev/$WINSYS"; then WINFS=$(probepart|grep "^/dev/$WINSYS"|cut -d'|' -f2) #[ "$WINFS" ] || break case "$WINFS" in ntfs) OPT=$MOUNTOPT ;; vfat) OPT="shortname=mixed,quiet,utf8" [ "$MOUNTOPT" ] && OPT="$OPT,$MOUNTOPT" ;; *) WINFS="" ;; esac if [ "$WINFS" ] ; then [ "$OPT" ] && OPT="-o $OPT" mkdir -p /mnt/$WINSYS mount -t $WINFS $OPT /dev/$WINSYS /mnt/$WINSYS fi fi fi DEVICES=$(mount 2>/dev/null |grep -E 'type[ ](vfat|ntfs|fuseblk)' | cut -d' ' -f1) || exit for DEVICE in $DEVICES do MOUNTPOINT=$(grep ^$DEVICE /etc/mtab | cut -d' ' -f2) || break for SWAP in $SWAPFILENAMES do SWAPFILE=$MOUNTPOINT/$SWAP [ -f $SWAPFILE ] && mkswap $SWAPFILE && swapon $SWAPFILE done for WINFONTS in $WINFONTSDIRS do TTFFONTS=$(ls -1 $MOUNTPOINT$WINFONTS/*.tt? $MOUNTPOINT$WINFONTS/*.TT? 2>/dev/null) if [ "$TTFFONTS" ]; then mkdir -p $LINFONTSDIR/winfonts for AFONT in $TTFFONTS; do ln -sf $AFONT $LINFONTSDIR/winfonts done fi done done ;; esac