miércoles, 13 de febrero de 2013

Network Manager and NFS problem on Shutdown

I power up my personal computer with debian system installed. I login and automatically my network manager connect to predefined wireless network because the application nm-applet (network manager applet) or similar has send the order to network manager daemon using dbus communication. I mount one folder using NFS o CIFS.
When i shutdown my computer the error message () appear at the end of shutdown process.
This situation is because the network manager daemon is release before unmount network file systems. The idea is correct because the network manager daemon establish a connection when the nm-applet send the order and the nm-applet only run when user as logging.  But the nfs is a basic part of system like networking. The problem is that networkmanager is used to respond user request (at user level) and change basic system configuration like network parameters. The nfs depend of network interfaces and is release before the network is down but it refer to basic networking daemon, not to networkmanager.
The network manager daemon can modify network connection but must take in consideration that it can release the current connection on shutdown because is the networking daemon who must to do it.
networking - work at system level
network file system - work at system an user level.
networkmanager - work at user level but modifying networking ( problem because start late in time and change system configuration that must be defined at system boot)

The solution is change the release order of daemon on system level 6 and 0. 

ls /etc/rc6.d/
...
K02network-manager -> ../init.d/network-manager
K03sendsigs -> ../init.d/sendsigs
K04rsyslog -> ../init.d/rsyslog
K05umountnfs.sh -> ../init.d/umountnfs.sh
K06nfs-common -> ../init.d/nfs-common
K06rpcbind -> ../init.d/rpcbind
K07hwclock.sh -> ../init.d/hwclock.sh
K07networking -> ../init.d/networking
K08umountfs -> ../init.d/umountfs
K09umountroot -> ../init.d/umountroot
K10reboot -> ../init.d/reboot

ls /etc/rc0.d/

K02network-manager -> ../init.d/network-manager
K03sendsigs -> ../init.d/sendsigs
K04rsyslog -> ../init.d/rsyslog
K05umountnfs.sh -> ../init.d/umountnfs.sh
K06nfs-common -> ../init.d/nfs-common
K06rpcbind -> ../init.d/rpcbind
K07hwclock.sh -> ../init.d/hwclock.sh
K07networking -> ../init.d/networking
K08umountfs -> ../init.d/umountfs
K09umountroot -> ../init.d/umountroot
K10halt -> ../init.d/halt

Move network-manager from position 2 to position 7 at the same level that networking because it do the same that networking at release (deconfigure network interfaces).

martes, 15 de enero de 2013

Moving out Firefox's profile to ram filesystem

Firefox's profile dir

Hi, I need to optimize firefox execution getting somes files out of disk to ram and come back to disk to retaing data. In linux firefox use the folder $HOME/.mozilla/firefox to store all available profiles. I use this script to make it possible.

FF_BIN=/opt/32/firefox/firefox
PROFILE_NAME=$USER

# Launch firefox with profile in ramfs, wait and update modified files to backup

RAMFS=/ramfs
PROFILE_ROOT=$HOME/.mozilla/firefox   #firefox root directory
PROFILE_FILE=$PROFILE_ROOT/profiles.ini

#check preconditions
[ ! -e $PROFILE_FILE ] && echo "error: not file $PROFILE_FILE " >> /opt/bin.log && exit


#read all section when name is present hold. for next keys use name.key = value

while IFS="\=" read -r key val ; do
    [ -z $val ] && continue             # eval -zero string if true eval continue, the result is not use

    if [ $key == "Name" ] ; then
        PREFIX=$val
        continue
    fi

    [ -z $PREFIX ] && continue

    export "${PREFIX}_$key=$val"        #make visible out of while do not use dot because it is not valid for variable name 

done < $PROFILE_FILE 

# copy to ramfs only one time, remain until next reboot, get backup on every exit
eval PROFILE_DIR=\$\{${PROFILE_NAME}_Path\}
eval PROFILE_PATH=$PROFILE_ROOT/\$\{${PROFILE_NAME}_Path\}

[ -z $PROFILE_DIR ] && echo "error: profile $PROFILE_NAME not found in $PROFILE_FILE " >> /opt/bin.log && exit
[ ! -d ${PROFILE_PATH}.backup ] && echo "error: directory ${PROFILE_PATH}.backup not found " >> /opt/bin.log && exit

RAMFS_PROFILE_PATH=${RAMFS}$PROFILE_PATH

if [ ! -d $RAMFS_PROFILE_PATH ] ; then
    mkdir -p $RAMFS_PROFILE_PATH
    cp -axr ${PROFILE_PATH}.backup/. $RAMFS_PROFILE_PATH
    ln -sf $RAMFS_PROFILE_PATH  $PROFILE_ROOT
fi

$FF_BIN -p $PROFILE_NAME -no-remote  $@

#update modified files
if [ ! -z $RAMFS_PROFILE_PATH ] ; then
# -E to preserve exection flag.
rsync -avqE --delete-after $RAMFS_PROFILE_PATH/. ${PROFILE_PATH}.backup
fi

exit