LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Improving Slackware (based) distros all to one new Slackware based distro (http://www.linuxquestions.org/questions/slackware-14/improving-slackware-based-distros-all-to-one-new-slackware-based-distro-620009/)

Secu-Slack 02-09-2008 09:17 PM

Improving Slackware to a new Slackware based distro.
 
Dear Slackware and other Linux/GNU veterans,

I'm collecting information for a new Linux project and I need your help with this.

As a starter, I'm placing a shutdown/reboot (rc.6) script here and I would like to hear from you what you're missing / added / changed in this script in your own distro and / or what you like to see in this script.

Thank you for your help.

--------------------------------------------------------------------------
Update 11-feb-08:
--------------------------------------------------------------------------
- Code: Filled with new idea's.
- People can cut and paste something useful from here.
--------------------------------------------------------------------------

Code:

#! /bin/sh
#
# rc.6                This file is executed by init when it goes into runlevel
#                0 (halt) or runlevel 6 (reboot). It kills all processes,
#                unmounts file systems and then either halts or reboots.
#
# Version:        0.1
#



echo -e '\E[36m'"\033[1mRunning shutdown script $0:\033[0m"

# Load global settings:
. /etc/rc.d/secu-slack.config &

# Set the path:
PATH=/sbin:/etc:/bin:/usr/bin &

# Set linefeed mode to avoid staircase effect:
stty onlcr

# Run SystemV init scripts for this runlevel:
if [ "$SYSINIT" = "1" ]; then
 . /etc/rc.d/rc.sysvinit
fi

# Find out what the user wants:
case "$0" in
        *0)
                command="halt"
                ;;
        *6)
                command="reboot"
                ;;
        *)
                echo -e '\E[31m'"\033[1m$0: call me as \"rc.0\" or \"rc.6\" please!\033[0m"
                exit 1
                ;;
esac


## Saving / updating data part:

# Save the system time to the hardware clock and check for a broken motherboard
# RTC clock (where ioports for rtc are unknown) to prevent hwclock causing a hang:
 if ! grep -q -w rtc /proc/ioports ; then
  CLOCK_OPT="--directisa"
 fi
  if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
  echo -e '\E[32m'"\033[1mSaving system time to the hardware clock (UTC).\033[0m"
  hwclock $CLOCK_OPT --utc --systohc &
  else
  echo -e '\E[32m'"\033[1mSaving system time to the hardware clock (localtime).\033[0m"
  hwclock $CLOCK_OPT --localtime --systohc &
  fi

# Save the sound settings:
if [ -x /usr/sbin/alsactl ]; then
 echo -e '\E[32m'"\033[1mSaving sound settings.\033[0m"
 /usr/sbin/alsactl store &
fi

# Update the shared library links:
if [ -x /sbin/ldconfig ]; then
 echo -e '\E[32m'"\033[1mUpdating shared library links.\033[0m"
 /sbin/ldconfig &
fi

# Update the X font indexes:
if [ -x /usr/bin/fc-cache ]; then
 echo -e '\E[32m'"\033[1mUpdating X font indexes:  /usr/bin/fc-cache.\033[0m"
 /usr/bin/fc-cache  2>&1 1>/dev/null &
fi


## Stopping services part:

# Run local shutdown scripts:
if [ "$RCLOCALSHUT" = "1" ]; then
 . /etc/rc.d/rc.local_shutdown
fi

# Stop the Apache2 (httpd) web server:
if [ "$APACHE" = "1" ]; then
 echo -e '\E[32m'"\033[1mStopping the Apache web server.\033[0m"
 . /etc/rc.d/rc.httpd stop &
fi

# Stop the MySQL database:
if [ "$MYSQL" = "1" ]; then
 echo -e '\E[32m'"\033[1mStopping the MySQL database.\033[0m"
 . /etc/rc.d/rc.mysqld stop &
fi

# Stop the Samba server:
if [ "$SAMBA" = "1" ]; then
 echo -e '\E[32m'"\033[1mStopping the Samba server.\033[0m"
 . /etc/rc.d/rc.samba stop &
fi

# Stop the NFS server:
if [ "$NFS" = "1" ]; then
 echo -e '\E[32m'"\033[1mStopping the NFS server.\033[0m"
 . /etc/rc.d/rc.nfsd stop &
fi

# Stop the SSH server:
if [ "$SSH" = "1" ]; then
 echo -e '\E[32m'"\033[1mStopping the SSH server.\033[0m"
 . /etc/rc.d/rc.sshd stop &
fi

# Stop the SASL authentication daemon:
if [ "$SASL" = "1" ]; then
 echo -e '\E[32m'"\033[1mStopping the SASL auth. deamon.\033[0m"
 . /etc/rc.d/rc.saslauthd stop &
fi

# Stop the OpenLDAP services:
if [ "$OPENLDAP" = "1" ]; then
 echo -e '\E[32m'"\033[1mStopping the OpenLDAP services.\033[0m"
 . /etc/rc.d/rc.openldap stop &
fi

# Stop the message D-Bus:
if [ "$DBUS" = "1" ]; then
 echo -e '\E[32m'"\033[1mStopping the message D-bus.\033[0m"
 . /etc/rc.d/rc.messagebus stop &
fi


## Unmount, stop processes and sync part:

# Unmount any NFS, SMB, or CIFS filesystems:
echo -e '\E[32m'"\033[1mUnmounting any remote NFS, SMB and CIFS filesystems:\033[0m"
umount -vart nfs,smbfs,cifs
 
# Try to stop pppd:
PS="$(ps ax)"
if echo "$PS" | /bin/grep -q -w pppd ; then
 if [ -x /usr/sbin/ppp-off ]; then
  ppp-off &
 fi
fi

# Bring down the networking system, but first make sure that this
# isn't a diskless client with the / partition mounted via NFS:
if ! /bin/mount | /bin/grep -q 'on / type nfs' ; then
 if [ "$RCINET1" = "1" ]; then
  echo -e '\E[32m'"\033[1mStopping the networking system.\033[0m"
  . /etc/rc.d/rc.inet1 stop &
 fi
fi

# In case dhcpcd might have been manually started on the command line,
# look for the .pid file, and stop dhcpcd if it's found:
if /bin/ls /etc/dhcpc/*.pid 1> /dev/null 2> /dev/null ; then
 echo -e '\E[32m'"\033[1mStopping the DHCP client deamon.\033[0m"
 dhcpcd -k 1> /dev/null 2> /dev/null &
fi

# Stop the PCMCIA devices:
if [ "$PCMCIA" = "1" ]; then
 echo -e '\E[32m'"\033[1mStopping the PCMCIA devices.\033[0m"
 . /etc/rc.d/rc.pcmcia stop &
fi

# Turn off process accounting:
if [ "$PACCT" = "1" ]; then
 if [ -x /sbin/accton -ar /var/log/pacct ]; then
  echo -e '\E[32m'"\033[1mTurning off process accounting.\033[0m"
  accton &
 fi
fi

# Kill all processes.
# INIT is supposed to handle this entirely now, but this didn't always
# work correctly without this second pass at killing off the processes.
# Since INIT already notified the user that processes were being killed,
# we'll avoid echoing this info this time around:
if [ ! "$1" = "fast" ]; then # shutdown did not already kill all processes.
 killall5 -15
 sleep 2
 killall5 -9
fi

# Try to turn off quota:
if [ "$QUOTA" = "1" ]; then
 if /bin/grep -q quota /etc/fstab ; then
  if [ -x /sbin/quotaoff ]; then
  echo -e '\E[32m'"\033[1mTurning off filesystem quotas.\033[0m"
  quotaoff -a &
  fi
 fi
fi

# Carry a random seed between reboots:
echo -e '\E[32m'"\033[1mSaving random seed from /dev/urandom in /etc/random-seed.\033[0m"
# Use the pool size from /proc, or 512 bytes:
if [ -r /proc/sys/kernel/random/poolsize ]; then
 dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(cat /proc/sys/kernel/random/poolsize) 2> /dev/null &
  else
  dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null &
  fi
  chmod 600 /etc/random-seed &

# Before unmounting file systems write a reboot or halt record to wtmp:
$command -w &

# Clear /var/lock/subsys:
if [ -d /var/lock/subsys ]; then
 rm -f /var/lock/subsys/* &
fi

# Clean /tmp of old and stale files:
echo -e '\E[32m'"\033[1mCleaning temporary files in /tmp.\033[0m"
find /tmp -type f -mtime +5 -exec rm -f {} \; &
find /var/tmp -type f -mtime +30 -exec rm -f {} \; &

# Turn off swap:
echo -e '\E[32m'"\033[1mTurning off swap.\033[0m"
swapoff -a &

# Umount any LVM volumes:
if [ "$LVM" = "1" ]; then
 if /bin/mount | /bin/grep -q '^/dev/mapper/' ; then
  echo -e '\E[32m'"\033[1mUnmounting LVM volumes:\033[0m"
  umount -v $(/bin/mount | /bin/grep '^/dev/mapper/' | /bin/cut -d ' ' -f 3 | /bin/tac)
 fi
fi

echo -e '\E[32m'"\033[1mUnmounting local filesystems:\033[0m"
umount -vart nonfs,noproc,nosysfs

# Close any volumes opened by cryptsetup:
if [ "$CRYPT" = "1" ]; then
 if [ -f /etc/crypttab -a -x /sbin/cryptsetup.static ]; then
  cat /etc/crypttab | grep -v "^#" | grep -v "^$" | while read line; do
  # NOTE: we only support LUKS formatted volumes (except for swap)!
  LUKS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f1 -d' ')
  DEV=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f2 -d' ')
  OPTS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f4 -d' ')
  if /sbin/cryptsetup.static isLuks $DEV 2>/dev/null ; then
  echo -e '\E[32m'"\033[1mLocking LUKS crypt volume '${LUKS}':\033[0m"
  cryptsetup.static luksClose ${LUKS} &
  elif echo $OPTS | grep -wq swap ; then
    # If any of the volumes was used as encrypted swap,
    # then run mkswap on the underlying device -
    # in case other Linux installations on this computer should use it:
    echo -e '\E[32m'"\033[1mErasing encrypted swap '${LUKS}' and restoring normal swap on ${DEV}:\033[0m"
    cryptsetup.static remove ${LUKS} &
    mkswap $DEV &
  fi
  done
 fi
fi

# Deactivate LVM volume groups:
if [ "$LVM" = "1" ]; then
 if [ -r /etc/lvmtab -od /etc/lvm/backup ]; then
  echo -e '\E[32m'"\033[1mDeactivating LVM volume groups.\033[0m"
  vgchange -an --ignorelockingfailure &
 fi
fi

# Remount read only anything that's left mounted:
echo -e '\E[32m'"\033[1mRemounting remaining filesystems as read-only:\033[0m"
mount | awk '/dev/ { print $3 }' | while read line; do
mount -vno ro,remount $line
done

# Turn off raid devices:
if [ -x /sbin/raidstop -a -f /etc/raidtab -a /proc/mdstat ]; then
 # We can not use raidstop -a here because this will only stop
 # devices listed in the default config file which is not always
 # the case. So we look only for the active raid devices:
 if [ -f /proc/mdstat ] ; then
  mddevs=$(grep ^md /proc/mdstat | awk '{ print $1 }')
  root=$(mount | grep "md.* \/ " | awk '{ print $1 }' | sed -e 's/\/dev\///')
  for mddev in $mddevs; do
  if [ $mddev != $root ]; then
    echo -e '\E[32m'"\033[1mTurning off RAID for $mddev.\033[0m"
    raidstop /dev/$mddev
  fi
    done
    unset mddev mddevs
 fi
fi

# This is to ensure all processes have completed:
sync
wait
sleep 1

if [ "$UPS" = "1" ]; then
 echo -e '\E[32m'"\033[1mChecking UPS.\033[0m"
 # See if this is a powerfail situation:
 if /bin/egrep -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then
  # Signal UPS to shut off the inverter:
  genpowerd -k
  if [ ! $? = 0 ]; then
    echo
 echo -e '\E[31m'"\033[1mThere was an error signaling the UPS.\033[0m"
 echo -e '\E[31m'"\033[1mPerhaps you need to edit /etc/genpowerd.conf to configure\033[0m"
 echo -e '\E[31m'"\033[1mthe serial line and UPS type.\033[0m"
    # Wasting 30 seconds of precious power:
    sleep 30
  fi
 fi
fi

# Now halt (poweroff with APM or ACPI enabled kernels) or reboot:
if [ "$command" = "reboot" ]; then
 echo -e '\E[31m'"\033[1mRebooting.\033[0m"
 reboot
 else
 echo -e '\E[31m'"\033[1mPoweroff.\033[0m"
 poweroff
fi


erklaerbaer 02-10-2008 10:06 AM

quite frankly, you are wasting your time. this kind of stuff has been done a thousand times before. naturally you are free to do whatever you fancy, but i;d propose that you divert your efforts to something more worthwile and submitting it upstream.

archtoad6 02-10-2008 11:02 AM

Welcome to LQ. :)

Wouldn't a pastebin is a much more appropriate place to post such a long script; & if you must post it here, please at least use "Code:" blocks.

hitest 02-10-2008 11:21 AM

Welcome to the LQ Forums:-) Good luck with your project:-)

vdemuth 02-10-2008 01:46 PM

# clean tmp of old and stale files
echo "Cleaning temporary files"
find /tmp -type f -mtime +5 -exec rm -f {} \;
find /var/tmp -type f -mtime +30 -exec rm -f {} \;



The above included in the shutdown script tends to keep your system cleaner

Good luck with your idea

Secu-Slack 02-10-2008 06:39 PM

Thank you for your help. I've placed it into the script where I think it should belong.

Quote:

Originally Posted by vdemuth (Post 3052615)
# clean tmp of old and stale files
echo "Cleaning temporary files"
find /tmp -type f -mtime +5 -exec rm -f {} \;
find /var/tmp -type f -mtime +30 -exec rm -f {} \;



The above included in the shutdown script tends to keep your system cleaner

Good luck with your idea


Secu-Slack 02-10-2008 06:51 PM

I would like to collect everything here.. at one place. Not some good script lines scattered over the internet and spitted out lines by distro maintainers they don't want. Put the ideas together and do something with it. Remove the old. improve the new. quoted now.

Quote:

Originally Posted by erklaerbaer (Post 3052435)
quite frankly, you are wasting your time. this kind of stuff has been done a thousand times before. naturally you are free to do whatever you fancy, but i;d propose that you divert your efforts to something more worthwile and submitting it upstream.


Secu-Slack 02-10-2008 07:02 PM

Thank you.. I think I need it:

Some will try to flame me. But I will not burn...

Luckily there are always some people that do understand and they will reach out a hand.

Quote:

Originally Posted by hitest (Post 3052484)
Welcome to the LQ Forums:-) Good luck with your project:-)


SqdnGuns 11-11-2008 06:51 PM

Project died?

Move thread to graveyard?

empcrono 11-11-2008 07:32 PM

For some reason the whole thing from the first post, (this is my first time reading it), seems so violent. Almost like he is, (and I believe), unintentionally,(or I may be wrong), inviting a flame war.

rworkman 11-11-2008 09:20 PM

Another attempt to ride on the coattails of Slackware - that's all.
If most of these "forks" were so damn good, they wouldn't have to throw around the "based on Slackware" stuff.

I'll leave open the possibility that there's a rare exception to this, but as I see it, the "fork" distributions aren't truly even forks. They "re-branch" with every stable Slackware release, and one even issues point releases at various spots based on the -current development tree. Essentially, they add/remove/modify a few things, rebrand it, and pull mindshare/marketshare/users/whatever from Slackware. A parasite that is too effective kills its host, and then they both die.

MS3FGX 11-11-2008 10:02 PM

Quote:

Some will try to flame me. But I will not burn...
It is a shame this project never got off the ground, that could have been the motto! Could put it on shirts and mugs.

mRgOBLIN 11-11-2008 11:03 PM

Quote:

Originally Posted by Secu-Slack (Post 3052913)
Some will try to flame me. But I will not burn...

Asbestos undies FTW!
(Govt Health Warning! Not recommended for panty sniffers)

sahko 11-12-2008 12:06 AM

Quote:

Originally Posted by rworkman (Post 3338964)
I'll leave open the possibility that there's a rare exception to this, but as I see it, the "fork" distributions aren't truly even forks. They "re-branch" with every stable Slackware release, and one even issues point releases at various spots based on the -current development tree. Essentially, they add/remove/modify a few things, rebrand it, and pull mindshare/marketshare/users/whatever from Slackware. A parasite that is too effective kills its host, and then they both die.

Thats the reason these parasitic (i agree 100% with the term) distributions are not successful. Neither of them. And neither of them ever will. They could just be addons to Slackware like gware and all other gnome providers for slackware and help upstream. Instead they take advantage of everything thats been committed upstream, code, packages, bugfixes, everything and give absolutely nothing back.
Most of them, as far as i have seen, just use other people's scripts (slacky.eu etc) to build the additional packages. I call that childish. Sure Pat V. says to have fun while doing it, learn, experiment. But is there really a point in releasing all those distros to public? There are around 20 Slackware clones that try to deal the same "gap". Package management (most of them using slapt-get) and having xfce instead of kde as their main desktop environment. When only 1 would suffice.
Oh well...

H_TeXMeX_H 11-12-2008 02:39 AM

Quote:

Originally Posted by rworkman (Post 3338964)
Another attempt to ride on the coattails of Slackware - that's all.
If most of these "forks" were so damn good, they wouldn't have to throw around the "based on Slackware" stuff.

I'll leave open the possibility that there's a rare exception to this, but as I see it, the "fork" distributions aren't truly even forks. They "re-branch" with every stable Slackware release, and one even issues point releases at various spots based on the -current development tree. Essentially, they add/remove/modify a few things, rebrand it, and pull mindshare/marketshare/users/whatever from Slackware. A parasite that is too effective kills its host, and then they both die.

Under the GPL there is no such notion as parasite. The code is there free for all to use, the only restriction is to release it free as well.

In "worst case scenario" (for the entity of Slackware), say someone forked Slackware and the fork was so good that everyone switched away from Slackware. That would simply mean that Slackware is obsolete, and the fork is better. What you are assuming is that the fork = parasite and somehow it will die because of this. Nonsense I say. So far no fork has ever gained much popularity, and if it has then it's because it offers something Slackware does not, in many cases it is a port such as slamd64, slackintosh, etc. The notion of parasite is more in line with M$ / EULA / software patents mentality. You obviously do not have the right to fork Window$ ...


All times are GMT -5. The time now is 11:05 PM.