mkwriteable

Messing around with cbagger's mkwriteable script, and came up with something that allows the user to specify which directories to open up. I figure this could be useful for someone who is sensitive to RAM usage but also wants to be able to write to a particular directory or directories.

This hasn't been thoroughly tested, but it seems to work.


#!/bin/bash
ARGS=$@
checkfile=/etc/sysconfig/writeable2
grep ^all $checkfile && exit
do_bin() {
cp -srd /KNOPPIX/bin/ /ramdisk
ln -sf /ramdisk/bin /
echo "bin" >> $checkfile
}
do_boot() {
cp -srd /KNOPPIX/boot/ /ramdisk
ln -sf /ramdisk/boot /
echo "boot" >> $checkfile
}
do_lib() {
cp -srd /KNOPPIX/lib/ /ramdisk
ln -sf /ramdisk/lib /
echo "lib" >> $checkfile
}
do_sbin() {
cp -srd /KNOPPIX/sbin/ /ramdisk
ln -sf /ramdisk/sbin /
echo "sbin" >> $checkfile
}
do_usr() {
cp -srd /KNOPPIX/usr/ /ramdisk
ln -sf /ramdisk/usr/X11R6/lib/X11 /ramdisk/usr/lib/
ln -sf /ramdisk/usr /
echo "usr" >> $checkfile
}
do_all() {
grep ^bin $checkfile || do_bin
grep ^boot $checkfile || do_boot
grep ^lib $checkfile || do_lib
grep ^sbin $checkfile || do_sbin
grep ^usr $checkfile || do_usr
cp -srd /KNOPPIX/var/cache/apt/ /ramdisk/var/cache
rm -rf /ramdisk/var/cache/apt/archives/lock
cp /KNOPPIX/var/cache/apt/archives/lock /ramdisk/var/cache/apt/archives
rm -rf /ramdisk/var/lib/apt
cp -srd /KNOPPIX/var/lib/apt/ /ramdisk/var/lib
rm -f /var/lib/dpkg
echo "all" > $checkfile
exit
}
[ ! "$ARGS" ] && do_all
for arg in bin boot lib sbin usr; do
check_args=`echo $ARGS | grep -w $arg`
check_done=`grep ^$arg $checkfile`
if [ "$check_args" ]; then
[ ! "$check_done" ] && do_$arg
fi
done

If the script is launched with no arguments, it should behave in basically the same way as the original.

Arguments are
bin
boot
lib
sbin
usr

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Very cool.

Thats very cool mikshaw, thanks for posting that. I'll add it to the documentation. I had written one for myself also, since my laptop has 32 megs of ram and i can rarely use any mydsls. =) This will be good for low ram users who with to use extensions. Thanks!

-william
tronik @ #damnsmalllinux irc.freenode.net

nice job

It's always a pleasure seeing your work.