LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-09-2008, 09:17 PM   #1
Secu-Slack
LQ Newbie
 
Registered: Feb 2008
Location: Netherlands
Distribution: Slackware
Posts: 5

Rep: Reputation: 0
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

Last edited by Secu-Slack; 11-12-2008 at 01:15 PM. Reason: Leveling
 
Old 02-10-2008, 10:06 AM   #2
erklaerbaer
Member
 
Registered: Mar 2006
Posts: 381

Rep: Reputation: 30
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.
 
Old 02-10-2008, 11:02 AM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
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.
 
Old 02-10-2008, 11:21 AM   #4
hitest
Guru
 
Registered: Mar 2004
Location: Canada
Distribution: Void, Debian, Slackware, VMs
Posts: 7,342

Rep: Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746Reputation: 3746
Welcome to the LQ Forums:-) Good luck with your project:-)
 
Old 02-10-2008, 01:46 PM   #5
vdemuth
Member
 
Registered: Oct 2003
Location: West Midlands, UK
Distribution: Slackware 14 (Server),OpenSuse 13.2 (Laptop & Desktop),, OpenSuse 13.2 on the wifes lappy
Posts: 781

Rep: Reputation: 98
# 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
 
Old 02-10-2008, 06:39 PM   #6
Secu-Slack
LQ Newbie
 
Registered: Feb 2008
Location: Netherlands
Distribution: Slackware
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you for your help. I've placed it into the script where I think it should belong.

Quote:
Originally Posted by vdemuth View Post
# 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
 
Old 02-10-2008, 06:51 PM   #7
Secu-Slack
LQ Newbie
 
Registered: Feb 2008
Location: Netherlands
Distribution: Slackware
Posts: 5

Original Poster
Rep: Reputation: 0
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 View Post
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.
 
Old 02-10-2008, 07:02 PM   #8
Secu-Slack
LQ Newbie
 
Registered: Feb 2008
Location: Netherlands
Distribution: Slackware
Posts: 5

Original Poster
Rep: Reputation: 0
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 View Post
Welcome to the LQ Forums:-) Good luck with your project:-)

Last edited by Secu-Slack; 11-12-2008 at 01:17 PM.
 
Old 11-11-2008, 06:51 PM   #9
SqdnGuns
Senior Member
 
Registered: Aug 2005
Location: Pensacola, FL
Distribution: Slackware64® Current & Arch
Posts: 1,092

Rep: Reputation: 174Reputation: 174
Question

Project died?

Move thread to graveyard?
 
Old 11-11-2008, 07:32 PM   #10
khronosschoty
Member
 
Registered: Jul 2008
Distribution: Slackware
Posts: 648
Blog Entries: 2

Rep: Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514Reputation: 514
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.
 
Old 11-11-2008, 09:20 PM   #11
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 2,559

Rep: Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351
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.
 
Old 11-11-2008, 10:02 PM   #12
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
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.
 
Old 11-11-2008, 11:03 PM   #13
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 231Reputation: 231Reputation: 231
Quote:
Originally Posted by Secu-Slack View Post
Some will try to flame me. But I will not burn...
Asbestos undies FTW!
(Govt Health Warning! Not recommended for panty sniffers)
 
Old 11-12-2008, 12:06 AM   #14
sahko
Senior Member
 
Registered: Sep 2008
Distribution: Slackware
Posts: 1,041

Rep: Reputation: Disabled
Quote:
Originally Posted by rworkman View Post
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...

Last edited by sahko; 11-12-2008 at 12:41 AM.
 
Old 11-12-2008, 02:39 AM   #15
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Quote:
Originally Posted by rworkman View Post
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$ ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorce based distro (gentoo) Vs Binary based distro(fedora, debian,..) ashwin_cse Linux - Distributions 7 02-08-2010 01:46 PM
Slackware 12.0 based distros are refusing to give me permission to write Rettic AC Slackware - Installation 2 08-14-2007 01:02 AM
Suggestions for a distro that is source based, non-slackware? rjohnson244 Linux - General 1 09-13-2006 08:35 AM
Do DEB-based distros have the dependancy hell like RPM-based ones? manhinli Linux - Newbie 2 04-05-2005 06:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration