#!/bin/sh
/usr/X11R6/bin/sessreg -a -w /var/log/wtmp -u /var/run/utmp -l $DISPLAY $USER

# set any options that might be in users IBMSetupInformationBlock
if [ -f $HOME/IBM/IBMSetupInformationBlock ]; then
   . $HOME/IBM/IBMSetupInformationBlock
   if [ "$LeftHandedMouse" = "1" ]; then
      /usr/X11R6/bin/xmodmap -e "pointer = 3 2 1"
   fi
fi

# Programming Note: Since only IBMSetup cares about this file, create the file
# in the same background process that IBMSetup is launched from. This improves
# login performance.
{
   # Source $LANG setup code common to all session scripts.
   . /etc/gdm/Sessions/Common/SessionLang


   # Source environment variable setup code common to all session scripts.
   . /etc/gdm/Sessions/Common/SessionEnvironmentVariables


   # Copy the /etc/motd file to /tmp/IBM/Messages, if needed.
   if [ -n "$NETVISTA_MOTD_FILE" -a -f "$NETVISTA_MOTD_FILE" ]; then
      mkdir -p /tmp/IBM/Messages
      cp $NETVISTA_MOTD_FILE /tmp/IBM/Messages
   fi


   # ---------------------------------------------------------------------------
   # Create the IBMSetup "Flags" file which toggles setup functions depending
   # on the state of the file system.
   # ---------------------------------------------------------------------------
   rm -rf /tmp/IBMSetup/Flags
   mkdir -p /tmp/IBMSetup
   chmod 600 /tmp/IBMSetup

   absfile=`/IBM/bin/absolute_path.sh $HOME`
   echo "home_dir_enabled=`/IBM/bin/file_on_persistent_storage.sh $absfile`" > /tmp/IBMSetup/Flags

   absfile=`/IBM/bin/absolute_path.sh /etc/sysconfig`
   echo "etc_sysconfig_enabled=`/IBM/bin/file_on_persistent_storage.sh $absfile`" >> /tmp/IBMSetup/Flags

   absfile=`/IBM/bin/absolute_path.sh /usr/local/lib/snmp/snmpd.local.conf`
   echo "snmp_trap_enabled=`/IBM/bin/file_on_persistent_storage.sh $absfile`" >> /tmp/IBMSetup/Flags

   absfile=`/IBM/bin/absolute_path.sh /IBM/autoupdate`
   echo "autoupdate_enabled=`/IBM/bin/file_on_persistent_storage.sh $absfile`" >> /tmp/IBMSetup/Flags

   absfile=`/IBM/bin/absolute_path.sh /etc/localtime`
   echo "etc_localtime_enabled=`/IBM/bin/file_on_persistent_storage.sh $absfile`" >> /tmp/IBMSetup/Flags

   absfile=`/IBM/bin/absolute_path.sh /root/IBM`
   echo "root_ibm_enabled=`/IBM/bin/file_on_persistent_storage.sh $absfile`" >> /tmp/IBMSetup/Flags

   chmod 600 /tmp/IBMSetup/Flags
   # ---------------------------------------------------------------------------


   exec /IBM/bin/IBMSetup
} &

