Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 16 Sep 2014, 03:38
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
ADVANCED pup-5xx /sbin/init
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 2 [23 Posts]   Goto page: Previous 1, 2
Author Message
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Sun 03 Jun 2012, 13:22    Post subject: Interval check  

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:

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 .
init-2.1.bz2
Description 
bz2

 Download 
Filename  init-2.1.bz2 
Filesize  16 KB 
Downloaded  274 Time(s) 
Back to top
View user's profile Send private message Visit poster's website 
sunburnt


Joined: 08 Jun 2005
Posts: 5028
Location: Arizona, U.S.A.

PostPosted: Mon 18 Jun 2012, 09:30    Post subject:  

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...
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Mon 18 Jun 2012, 09:53    Post subject:  

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 .
Back to top
View user's profile Send private message Visit poster's website 
linuxcbon

Joined: 09 Aug 2007
Posts: 762

PostPosted: Sat 21 Jul 2012, 12:31    Post subject:  

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 ?
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Mon 23 Jul 2012, 21:22    Post subject:  

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 .
Back to top
View user's profile Send private message Visit poster's website 
linuxcbon

Joined: 09 Aug 2007
Posts: 762

PostPosted: Mon 23 Jul 2012, 22:15    Post subject:  

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.
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2247

PostPosted: Tue 24 Jul 2012, 05:06    Post subject:  

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:
fi #6
#echo $LINENO
else #5
FSCK=''
fi #5
#echo $LINENO
fi #3
fi #2.1
fi ##2
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 3972
Location: Kiel,Germany

PostPosted: Tue 24 Jul 2012, 14:21    Post subject:  

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 .

Quote:
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 !

[url=http://en.wikipedia.org/wiki/Jacob's_Ladder]Jacob's Ladder[/url]is 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 !
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 2 of 2 [23 Posts]   Goto page: Previous 1, 2
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0942s ][ Queries: 13 (0.0134s) ][ GZIP on ]