sidux.com
Menu

News

Give back
Last 3 Contributions
30-11-2008 20.00
25-11-2008 100.00
25-11-2008 20.00

Donate


Sponsor
hetzner.de

Languages
Preferred language:



Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
ModestUser
Post subject: Charon takes you to runlevel 3 and back  PostPosted: Jul 14, 2008 - 10:41 PM



Joined: Jan 07, 2008
Posts: 298

Status: Offline
Tired of Ctrl-Alt-F1, typing your root password again, doing smxi, sgfxi or apt-get dist-upgrade and moving back to runlevel 5?

This script performs a smooth transition to runlevel 3, executes an arbitrary command or program (smxi, sgfxi, apt-get, ...) and goes back to runlevel 5. It support session logging via the option -l. Try it, this is very useful in case something went wrong with your d-u.

Examples (e.g. in KDE)
Code:

charon smxi

or
Code:

charon apt-get update && apt-get dist-upgrade


to get session logging:
Code:

charon -l apt-get dist-upgrade

After this, you will have a file in /var/log/charon/ that contains everything that was displayed on your screen during that command.

Installation: save to /tmp/charon.zip
as root:
cd /usr/local/bin
cp /tmp/charon.zip .
unzip charon.zip

I am happy for any bug reports. charon is usually depicted as an ugly man and so is this code. Use with caution. It is really a dirty hack ... but it works great here.

changelog 0.2:
- added trapping, so CTRL-C will take you back to RL 5
- addeds session logging
- add a lock, so there can be only one instance of charon running on a tty
- do not do init 5 if there is dpkg/apt-get/smxi/sgfxi running.
- display a message on the VT after a command has been terminated


Last edited by ModestUser on Jul 18, 2008 - 04:34 PM; edited 3 times in total
 
 View user's profile Send private message  
Reply with quote Back to top
michaaa62
Post subject: Charon takes you to runlevel 3 and back  PostPosted: Jul 15, 2008 - 07:23 AM



Joined: Feb 24, 2007
Posts: 679
Location: Berlin, Germany
Status: Offline
Nice one, i just did my du with it.

Did you pm h2? He was asking in another threat for such a script to make it possible to run smxi from X and return to X afterwards.

I had to reboot because of a new kernel anyway, but are there any left-over pieces of the older, 'su'-ed sessions?
To use charon i had to cd to the directory, that contains charon to execute it, although the directory was in my path. It there a way to change that?

cheers Micha

_________________
http://sidux.com/PNphpBB2-viewtopic-t-2403.html
 
 View user's profile Send private message  
Reply with quote Back to top
ModestUser
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 15, 2008 - 12:14 PM



Joined: Jan 07, 2008
Posts: 298

Status: Offline
- No, there are no leftover root sessions. The X terminal is killed along with init 3 and the shell on the tty ends with the command.
- It should start from /usr/local/bin now without problems. Thanks a lot for the bug. That was a restarting problem.
 
 View user's profile Send private message  
Reply with quote Back to top
h2
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 15, 2008 - 06:07 PM



Joined: Nov 28, 2006
Posts: 4302

Status: Offline
I'll be doing an update on smxi to remove the init 3 component, leaving only the kill x/kde part, but it will also have to still support users who start from init 3 anyway, to bring them to init 5 if it's that type of system.

There are currently a wide range of options I'm seeing real world users running, and it's making the init 3 part of smxi basically worthless from what I can see.

Once I have this stuff worked out, maybe today, I'll start looking at the charon stuff, which I'm sure, based on modestuser's earlier work, will be very interesting.

_________________
sidux Maintenance script: dist-upgrade, kernel install, general utilities: smxi
Backup script [using rdiff-backup]: rd-h2.sh
 
 View user's profile Send private message  
Reply with quote Back to top
h2
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 15, 2008 - 09:43 PM



Joined: Nov 28, 2006
Posts: 4302

Status: Offline
I've removed the init 3 thing in smxi for shut x, but it will still start the default system init level on start desktop.

I found one strange thing, which I can't figure out how to resolve, the pid for for example kdm does not vanish when you do /etc/init.d/kdm stop, this is unfortunate, and might require a closer look because otherwise smxi will always try to kill x again even though smxi has already shutdown kdm/x.

_________________
sidux Maintenance script: dist-upgrade, kernel install, general utilities: smxi
Backup script [using rdiff-backup]: rd-h2.sh
 
 View user's profile Send private message  
Reply with quote Back to top
dzz
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 17, 2008 - 10:26 AM



Joined: Dec 21, 2006
Posts: 297
Location: Slough, England
Status: Offline
Interesting. Seems to work although I had to stop smxi this morning because sun-jre would be removed, maybe that will be fixed later. Straight back to kde after smxi exit. I see only a few have downloaded charon so far.

I tried opening a second terminal (alt+f2) to paste smxi output as I can never remember how to answer the config questions. You can't always scroll back far enough.

Unfortunately alt+F1 then gave just a root shell with no evidence of smxi. Something was running somewhere because a second attempt gave "dpkg locked in another process" error but I couldn't find why or where so had to reboot.
 
 View user's profile Send private message  
Reply with quote Back to top
muchan
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 17, 2008 - 10:58 AM



Joined: Aug 24, 2007
Posts: 472
Location: Ljubljana
Status: Offline
dzz, just a guess, but you can try Alt+F8 or Alt+F6.. (Alt+F7 is X windows)
the next free number is used to create new virtual machine.
 
 View user's profile Send private message  
Reply with quote Back to top
ModestUser
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 17, 2008 - 11:08 AM



Joined: Jan 07, 2008
Posts: 298

Status: Offline
Most likely smxi was running at /dev/tty8. You can switch there with CTRL-ALT-F8. charon does no dpkg or apt-get at all, so your dpkg locked problem should not be related to this. If however this is reproducible, please report.
 
 View user's profile Send private message  
Reply with quote Back to top
michaaa62
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 17, 2008 - 04:29 PM



Joined: Feb 24, 2007
Posts: 679
Location: Berlin, Germany
Status: Offline
Hi ModestUser,
so far caron smxi and charon ceni work flawless on my erebos system, but it makes me wonder why the kde-session is available so much faster for the second kdm process.
cheers Micha

_________________
http://sidux.com/PNphpBB2-viewtopic-t-2403.html
 
 View user's profile Send private message  
Reply with quote Back to top
dzz
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 17, 2008 - 04:33 PM



Joined: Dec 21, 2006
Posts: 297
Location: Slough, England
Status: Offline
Got my terminal at tty2 running nano at the same session and.......you're right, smxi still there at tty8, didn't look there!

As for the dpkg lock, I had part-run smxi at the time. I then lost smxi after opening another tty and got back to X by doing init 5 there. At that point apt itself was likely interrupted while still busy, maybe waiting for instruction.. So probably not looking at the charon script itself for the cause of that.

Anyway, I'll test charon some more when DU looks clean.

Would not a prompt at script execution to advise what will happen and wait for user input (y or n) be worth adding?
 
 View user's profile Send private message  
Reply with quote Back to top
dzz
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 17, 2008 - 06:33 PM



Joined: Dec 21, 2006
Posts: 297
Location: Slough, England
Status: Offline
I reproduced the error.
Apt was still active, waiting for an answer

56 upgraded, 4 newly installed, 1 to remove and 3 not upgraded.
Need to get 56.3MB of archives.
After this operation, 43.8MB disk space will be freed.
Do you want to continue [Y/n]?

After restarting X from another tty the one running smxi (apt at that point) was still active. In fact, doing charon smxi again, two copies of smxi were found running!

So the script itself is good, just be careful to exit any other terminals cleanly.
 
 View user's profile Send private message  
Reply with quote Back to top
h2
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 17, 2008 - 06:44 PM



Joined: Nov 28, 2006
Posts: 4302

Status: Offline
Re checking configs/warnings, once you have started smxi, and the dist-upgrade has begun, all you need to do is switch to another tty, and start smxi again like this: smxi -W cw

This will show the configs and the warnings/alerts. -W c shows only configs, -W w shows only warnings.

If you start smxi -W.. as root, it will also update the warnings/configs to latest, if you start as user, it will just use the last versions from the last time smxi warnings ran pre du.

Re the other stuff, I'm interested to see how this all works out in terms of especially supporting kill.

Keep in mind as well, during the du, smxi has a trap function to remove any holds, so it's important that that works as well.

_________________
sidux Maintenance script: dist-upgrade, kernel install, general utilities: smxi
Backup script [using rdiff-backup]: rd-h2.sh
 
 View user's profile Send private message  
Reply with quote Back to top
ModestUser
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 17, 2008 - 07:52 PM



Joined: Jan 07, 2008
Posts: 298

Status: Offline
@dzz: that apt-get process that you quote asks for an answer. Did you press 'n' <RETURN>? This is decisive here. If a process like apt-get or smxi ends, its output is still on that screen available via CTRL-ALT-Fx, but it is not running anymore. But i agree, it might be confusing to tell what is running and what not. I will make some improvements tonight.

@h2: Maybe you could add a lock for smxi to prevent multiple instances of smxi running? Or even checking for dpkg / apt-get locks?
 
 View user's profile Send private message  
Reply with quote Back to top
h2
Post subject: RE: Charon takes you to runlevel 3 and back  PostPosted: Jul 17, 2008 - 07:59 PM



Joined: Nov 28, 2006
Posts: 4302

Status: Offline
It's a feature now for multiple instances of smxi to run, that's how you use the smxi -W option during a smxi dist-upgrade session, for example. However, the -W option simply prints out the data and exits.

Checking for apt-get locks you can do, but usually apt get will let you know that anyway.

_________________
sidux Maintenance script: dist-upgrade, kernel install, general utilities: smxi
Backup script [using rdiff-backup]: rd-h2.sh
 
 View user's profile Send private message  
Reply with quote Back to top
dzz
Post subject:   PostPosted: Jul 17, 2008 - 10:02 PM



Joined: Dec 21, 2006
Posts: 297
Location: Slough, England
Status: Offline
@ModestUser
No, I did not hit
'n' <RETURN>
because I did not know at the time how to get back there to do it, having gone to tty2 to paste the output! Normally we do the DU in tty1.

Naturally, apt griped when invoked later.

That or other problems could probably happen by user error with or without charon; doing multiple tty's, not exiting cleanly then restarting X.

Your script is not to blame for that, it's very good indeed. A short warning before execution, as I suggested earlier, might help a first-time user though.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
 
Logos and trademarks are the property of their respective owners, comments are property of their posters, the rest is © 2006-2008 by sidux e.V., 10407 Berlin, Kniprodestr. 104. sidux e.V. is a Berlin, Germany based non-profit foundation. Consult Impressum and Legal Terms for details. sidux™ is Free Software released under the GNU/GPL license and other compatible licenses.
powered by Zikula & Zafenio