Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
OpenRC auto-login and auto-startx issue
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
sebaro
Veteran
Veteran


Joined: 03 Jul 2006
Posts: 1141
Location: Romania

PostPosted: Tue Aug 15, 2017 7:26 pm    Post subject: OpenRC auto-login and auto-startx issue Reply with quote

I've added "--autologin sebaro" to the agetty command for the first tty and put these in ~/.profile:
https://wiki.gentoo.org/wiki/X_without_Display_Manager#Starting_X11_on_console_login

It works for both OpenRC and systemd, the issue is when rebooting/powering off with OpenRC, it keeps restarting X until it reboots/powersoff.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 10024
Location: almost Mile High in the USA

PostPosted: Wed Aug 16, 2017 2:47 pm    Post subject: Reply with quote

Hmm...interesting.

Traditionally there should be a temporary "/etc/nologin" file to tell login to prohibit logins during shutdown/reboot, but it seems to not use this during the actual reboot (or --autologin ignores that fact).

You probably can work around this fact by checking the current runlevel and don't startx when it's trying to reboot or shutdown. /sbin/runlevel or 'who -r' will tell your current runlevel. Look in /etc/inittab for "id" for the default runlevel and only startx when the current runlevel matches the default runlevel:

Code:
if [ $(who -r|awk '{print $2}') = $(grep ^id: /etc/inittab |cut -f2 -d:) ]; then
echo starting x11...
startx
else
echo not in normal runlevel due to reboot or shutdown, sleeping...
sleep 30;
fi


(actually I'm not sure this works, and thinking that there might be a race condition on boot-startup. YMMV. Probably best to detect if it's in either reboot or shutdown and don't startx when in these cases.)

systemd probably simply "works" because of some other mechanism as things are more tightly integrated together.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
sebaro
Veteran
Veteran


Joined: 03 Jul 2006
Posts: 1141
Location: Romania

PostPosted: Wed Aug 16, 2017 6:51 pm    Post subject: Reply with quote

That's the solution I've been thinking about.
The problem is that '/sbin/runlevel' and 'who -r' don't work because I'm using openrc-init as init not sysvinit.

OpenRC stores the runlevel in /var/run/openrc/softlevel but I'm not sure how accurate it is.
This seems to be working fine so far.
Code:

if [[ -t 0 && $(tty) == /dev/tty1 && ! $DISPLAY ]]; then
   if ! grep -q "shutdown" "/var/run/openrc/softlevel"; then
     exec startx &>/home/.session.log
   fi
fi

This should be working too:
Code:
if grep -q "default" "/var/run/openrc/softlevel"; then
Back to top
View user's profile Send private message
sebaro
Veteran
Veteran


Joined: 03 Jul 2006
Posts: 1141
Location: Romania

PostPosted: Thu Aug 17, 2017 5:14 am    Post subject: Reply with quote

The startx issue seems to be solved but I've found the same issue with autologin. It repeats until agetty is stopped.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
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