ADVANCED pup-5xx /sbin/init

Under development: PCMCIA, wireless, etc.
Message
Author
User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

Interval check

#16 Post by Karl Godt »

After running it a long time now, i think i release version 2 of my /sbin/int .

It has a check for mount intervals and day check intervals :

Code: Select all

ERRFLG_FUNC() {  ###KRG
echo -e "\\033[1;34m"'Checking for unpropper previous shutdown  ... '"\\033[0;39m"
echo -n -e "\\033[1;33m"'Searching for *fsckme* file 3 levels deep ... '"\\033[0;39m"
ErrFlag=`busybox find / -maxdepth 3 -type f -iname '*fsckme*' | head -n1`  ###KRG 3 deep for fsckme.file@etc @boot @$HOME ..etc..
if [ -z "$ErrFlag" ] ; then  ##1
echo -e "\\033[56G\\033[1;5;32m"'Hurray , not found !'"\\033[0;39m"
echo -e "\\033[1;33m"'Checking for filesystem check intervals using'"\\033[0;39m"
LANG=C
VARS=`dumpe2fs $DEVROOTDRIVE | grep -E 'Maximum mount count|Mount count|Next check after|Check interval'`
###+++2011-11-15 had logically removed this ; would have been a bug due interN used further down
interC=`echo "$VARS" | grep 'Check interval' | tr '\n' ' '`
interN=`echo "$interC" | tr -s ' ' | cut -f 3 -d ' ' | grep -o -e '[[:digit:]]*'`
interN=$((interN/60/60/24))
 ###+++2011-11-15
nextch=`echo "$VARS" | grep 'Next check after' | tr '\n' ' '`
nextcM=`echo "$nextch" | tr -s ' ' | cut -f 5 -d ' '`
nextcD=`echo "$nextch" | tr -s ' ' | cut -f 6 -d ' '`
#echo "$nextch" ##+++2012-01-11
nextcY=`echo "$nextch" | tr -s ' ' | cut -f 8 -d ' '` ##+++2012-01-11 major bug !!
todays=`date`
todayY=`echo "$todays" | tr -s ' ' | cut -f 6 -d ' ' | tr -d [[:punct:]]`  ##+++ 2011_11_15 from luci218
todayM=`echo "$todays" | tr -s ' ' | cut -f 2 -d ' ' | tr -d [[:punct:]]`  ##lang dependent pos
todayD=`echo "$todays" | tr -s ' ' | cut -f 3 -d ' ' | tr -d [[:punct:]]`
mntcnt=`echo "$VARS" | grep 'Mount count'| grep -o '[[:digit:]]' | tr -d '\n'`
maxmnt=`echo "$VARS" | grep 'Maximum mount count' | grep -o '[[:digit:]]' | tr -d '\n'`
diffMC=$(( $maxmnt - $mntcnt ))
monthN=`for i in $(seq 1 12) ; do cal $i 1 | head -n 1 | grep -o '[[:alpha:]]*' | sed "s/^/$i /"; done`
monthT=`echo "$monthN" | grep "$todayM"`
montTN=`echo "$monthT" | cut -f 1 -d ' '`
monthC=`echo "$monthN" | grep "$nextcM"`
montCN=`echo "$monthC" | cut -f 1 -d ' '`
val30C=`cal $montCN 1 | grep '[[:digit:]]$' | sed '/^$/d' | tail -n 1 | grep -o -e '[[:digit:]]*$'`
##+++ 2011_11_15 from luci218
val30B=0
for i in `seq $((montCN+1)) $((montTN-1))` ; do
val30i=`cal $i 1 | grep '[[:digit:]]$' | sed '/^$/d' | tail -n 1 | grep -o -e '[[:digit:]]*$'`
val30B=$((val30B+val30i))
done
##+++ 2011_11_15 from luci218
val30T=`cal $montTN 1 | grep '[[:digit:]]$' | sed '/^$/d' | tail -n 1 | grep -o -e '[[:digit:]]*$'`
echo -e "\\033[0;39m"
#echo $LINENO $todayY $nextcY
FSCK=
if [ "$mntcnt" -ge "$maxmnt" ] ; then  ##2
echo -e "\\033[1;33m"'Maximum mount count reached'"\\033[0;39m"
FSCK='yes'
##fi  ##2
#echo $LINEMO
else ##2
if [ "$todayY" -ge "$nextcY" ] ; then #2.1 ##+++2011_11_15 from luci218
#echo $LINENO
if [ "$montTN" = "$montCN" ] ; then #3
#echo $LINENO
if [ "$todayD" -gt "$nextcD" ] ; then  #4
echo -e "\\033[1;33m"'Day interval reached'"\\033[0;39m"
FSCK='yes'
fi #4
#echo $LINENO
else #3
#echo $LINENO
if [ "$montTN" -gt "$montCN" ] ; then #5
MinusTD=$todayD
PlusCD=$(( $val30C - $nextcD ))
##+++2011_10_19 month difference missing val30B
SUM=$(( $MinusTD + $val30B + $PlusCD ))
#echo $LINENO
if [ "$SUM" -gt "$interN" ] ; then #6
echo -e "\\033[1;33m"'Day interval reached'"\\033[0;39m"
FSCK='yes'
fi #6
#echo $LINENO
else #5
FSCK=''
fi #5
#echo $LINENO
fi #3
fi #2.1
fi ##2
#echo $LINENO
if [ -z "$FSCK" ] ; then #7
echo -e "\\033[1;32m"'OK , '"\\033[0;32m""next check '$nextcM $nextcD' or in '$diffMC' mounts""\\033[0;39m"
echo -e "\\033[0;39m"
BUSYBOX_INIT_FUNC
#echo $LINENO
else #7
echo -e "\\033[1;33m"'Filesystem check interval reached :'"\\033[0;39m"
echo -e "\\033[0;33m"'Today : '"\\033[0;33m""$todayM $todayD""\\033[0;33m"' , next check was or would be : '"\\033[0;33m""$nextcM  $nextcD""\\033[0;33m"
echo -e "\\033[0;33m"'mount intervals : '"\\033[0;33m""$mntcnt""\\033[0;33m"' of '"\\033[0;33m""$maxmnt"
echo -e "\\033[0;39m"
fi #7
#echo $LINENO
else #1
echo -e "\\033[1;31m" ' Found : '"\\033[0;39m""\\033[1;5;31m""$ErrFlag"
echo -e "\\033[0;39m"
fi #1
}
Note 1 :
I have put a removal of /var/tmp and /tmp gets moved to /var/tmp/ .
Note 2 :
Due to giving access to keyboard i have put in a lot of the module loading part of rc.sysinit .
Note 3 :
I am working on implementing other filesystem capabilities atm , reiserfs 3x first .
Attachments
init-2.1.bz2
(16 KiB) Downloaded 452 times

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#17 Post by sunburnt »

Wow, the amount of code is staggering, much more than Tiny Core.

And even it has more than is needed for a simplified setup, as it makes
masses of links and has it`s app. loading / unloading method code.

I didn`t catch what your new init code does for Puppy...

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#18 Post by Karl Godt »

sunburnt wrote:Wow, the amount of code is staggering, much more than Tiny Core.

And even it has more than is needed for a simplified setup, as it makes
masses of links and has it`s app. loading / unloading method code.

I didn`t catch what your new init code does for Puppy...
The main purpose is to have an interactive and debugging mode .

Fsck -y automatically repair without questions can mess up things ie move a lot files to /lost+found like windows chkdsk to /found.000 .

On both OS Linux+Win these files get numbered names, so they become nearly impossible to recover correctly, especially the small files . 100 Mb files could be easily thought they may be some .sfs or .iso but how to recover /boot/grub for example if its files get named like

found_001.chk
found_002.chk
.
.
.

If you ever have experienced such on both OS like me you want to make a fsck -n or -i first to get an overview .

Parts of the code are also experimental mounting a sfs found somewhere on disk in case the needed binaries are corrupted too .

I have implemented a check for glibc version which might not be needed .

I could think of the whole put in an initrd.gz for full installs , where it would not need to check /lib for size, pivot_root and that all .

This /sbin/init is intended for people that want not much "Crunchbang" to their HDD .

linuxcbon
Posts: 1312
Joined: Thu 09 Aug 2007, 22:54

#19 Post by linuxcbon »

Nice theory but nobody will use it. Could you please make a puppy derivative with all your scripts ? Can you make them work with busybox ash ?

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#20 Post by Karl Godt »

I am on full installations mainly and there are so many Puppies out and Projects that it should be OK for me not to make a Derivate for now .

I am enjoying my adjustments which are different everywhere with their ugly debugging output . Not sure if that would be successful since such is not common .

I really do like busybox and i don't call it a "crippled whatsever" but ash has some disadvantages to bash :

no arrays
type has no -a option

for example .

Hardware that survived older Puppy versions rc.shutdown for example i think you can busybox poweroff without getting nightmares .

I am not the real minimalist , my RAM stated once with 320 MB . I have configured my kernels with both SATA and IDE inside and enjoing them .

There are some testers out there that complain about empty folders . Who needs them ?

But now i have problems with newer Hardware with Xorg for example . Some kernel configurations i thought would work don't work anymore and am regretting that i thrashed some kernels that did not work back then . My main kernel compiling machine died and i would have to setup a new one .

Today i struggled with testdisk for example after i accidentally did a cp /file /dev/hda which destroyed the MBR . The problem was the extended part of the partitions and after several attempts testdisk was able to dd the (two) partitions in question and the correct one was able to mount to recover but testdisk ordered my disordered physical/numbered partiton table and i had to get grub installed and find me a backup menu.lst and change the root (hdx,y) and root=/dev/hdaz entries .

Such things happen to me every day . Compiling can turn out very troublesome hunting dependencies, fixing the various [qic*]makes, fixing header structures, I mostly compile "./configure" that probably is not Puppy-like (i486) . Must say my HW started with i686 .

And for this particular /sbin/init i need a new HDD to experiment with other filesystems which could be possible since i was able to spare for two new ones; mail came yest/oday at least one can be picked up in some hours .

And i even think that is useless since it seems that really most people run Puppy frugally, which i can not understand since i once started with kernel 2.2 series suse-linux once when such loop mounting probably was not invented back then having had no telephone nor router .

And there is so many testing Puppy.iso ~ twice a week : enjoy them !

And for fsck : Because of my desaster today i had to fsck /dev/hda1 which got the superblock overwritten and for the record : Linux fsck names the files in lost+found "#NUMBER" without an extension .

Another idea i developed today is to add a mbr_backup.txt file to contain fdisk -l, date, and file output so i now which mbr.NUMBER is the one to be used; had grub4dos on hda1 and menu.lst was gone . I really like grub4dos but on toplevel of first drive I never really felt comfortable, and mostly stay with legacy grub .

linuxcbon
Posts: 1312
Joined: Thu 09 Aug 2007, 22:54

#21 Post by linuxcbon »

Karl Godt wrote:and such really not relevant remarks , except your are < a towards zero extremist > .
Karl Godt wrote:There are some testers out there that complain about empty folders . Who needs them ?
Last time I didn't want to answer but now, please don't talk to me anymore. Bye.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#22 Post by amigo »

Ever heard of indenting your code?? I could easily tell what your code is doing if it was formatted to be readable. But code like that makes me cringe -I won't even try to read a single line of that mess, hence I would never try it out either! You know, formatting would be helpful for you also -when you are debugging or three months from now when you look at that code again.

This is classic:

Code: Select all

fi #6 
#echo $LINENO 
else #5 
FSCK='' 
fi #5 
#echo $LINENO 
fi #3 
fi #2.1 
fi ##2

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#23 Post by Karl Godt »

amigo,you once said that Barry's code is a nightmare to read .
I agree with that totally for i am not an educated programmer .
4. (Print.) To begin (a line or lines) at a greater or less
distance from the margin;
NO!
This is the way i developed it for me, because indenting never made code clearer to me .

It makes it more difficult to test by copy and pasting to xterm .

I really don't know why this indenting ever ever was developed at all !

Jacob's Ladderis to watch if clear sky in probably 3 weeks from now if i look south up here as Milky Way in the open nature .

I don't need jacobs ladder on screen !

Post Reply