I issued the wrong systemctl.unit directive and now I cannot get to a shell.
I am on fedora 23, I changed runlevel by issuing
systemctl set-default rescue.target
Now the rescue mode gets stuck and never brings up the shell.
I have tried adding to the kernel
systemd.unit=graphical.target
But I keep getting kicked to rescue mode
Try pass the following line to kernel param:
systemd.unit=multi-user.target
With rescue.target the bash should normally already be brought up.
Maybe there is something not working even before rescue.target and prevent systemd reaches bash.
Try:
systemd.unit=emergency.target
or even pass:
init=/bin/sh
Related
What I'm trying to do
Okay so I've been trying to create a custom lockscreen on ubuntu using i3lock.
I achieved something I'm comfortable with as a lockscreen, but now I want to use this lockscreen instead of the default gnome one.
So I'm using xautolock for that, which works well when typed in a terminal, but that means I have to enter this manually each time I turn my pc on.
So right now I'm trying to making it a systemd service, and that's where I struggle.
What I block on
First thing is: executing the xautolock command in a shell script doesn't even work.
`#!/bin/bash
`xautolock -time 1 -locker mylock.sh #this line works in CLI but suspend the console
(I've done a chess game on my phone to wait, it lasted way longer than a minute and it didn't do anything whereas executing it in terminal works well)
So there is this problem, but wait there is more!
I've done the .service file, and running mylock.sh from the service returns an exit status=1/FAILURE.
Thus my incomprehension, because the line works in the console, and executing the shell script manually blocks the console aswell so I assume it doesn't fail (it doesn't work as expected tho)
I've tried two different configs for the service:
First one with ExecStart=/usr/bin/xautolock -time 1 -locker <path_to_my_lock>/mylock.sh
Which outputs (code=exited, status=1/FAILURE)
In the other one I tried to executed the a "lockservice.sh" script containing the xautolock line (which has no chance to work given the previous tests):
ExecStart=/bin/bash /PATH/lockservice.sh
Same thing: (code=exited, status=1/FAILURE)
I did a systemctl daemon-reload everytime, I chmoded 755 all the shell scripts. I also tried to execute the service with User=root
What I would like
I basically want something that can replace the gnome default lockscreen with my custom lock script, using xautolock and services isn't mandatory to me, but I'd like not having to run it manually on startup.
Thanks in advance !
I would like to execute tmux upon logging into a shell for my user. I am using fish, but I think this question is relevant to any shell. So far, I've accomplished this by following the advice in this question: https://askubuntu.com/questions/560253/automatically-running-tmux-in-fish, specifically, adding the following line to my config.fish:
test $TERM != "screen"; and exec tmux
However, I have one major issue with this approach, and that is if tmux fails to start, perhaps if I've introduced a syntax error in my .tmux.conf file, the shell process immediately exits, booting me out of the session.
Is there a way to automatically run tmux in new shell executions whereby I can:
Catch errors and fallback on a "plain" shell execution (i.e. just fish without tmux)
Not have to exit a login twice - once to quit tmux then again to quit fish
?
I imagine tmux exits with a non-zero (i.e. failing) status if there's configuration errors, so you could presumably ditch the exec and exit manually, like
if test $TERM != "screen"
tmux
and exit
end
However, do keep in mind that fish always sources all of its config files, so you'll want to wrap this inside if status --is-login or similar.
This works for me:
if status --is-login
source $HOME/.config/fish/login.fish
tmux; and exec true
end
Obviously you may or may not have a login.fish file. I like to keep my config.fish lean by putting code that might not be needed for the current session in separate files so I've also got a interactive.fish script
When I issue power off to a device, ideally the kernel should get this event and then runlevel 0 should get executed.
As of now the hardware turns off but the runlevel 0 is not executed.
When i manually executed the script
/etc/rc.d/rc
and hardcoded the runlevel value to 0 the script works fine and the system is halted.
All the services of halt,reboot are present in /etc/init.d directory
your runlevel specific services are present in /etc/rc.d/ directory
rc.d directory convention was quite old
Actually the changing of the run-level is done by the kernel modules the issue in my case was the binary that was responsible for issuing this reset was not packaged as it was missing in our package mapping list
I am trying to connect the remote ssh server via ruby using
Net::SSH.It is working fine for me for all the commands provided via
script and i could able to read the output of the command
successfully. But when i use the below command it is getting stuck in
SSH.exec!(cmd) and control is not returned from the line. Only if i
click Ctrl+c in command line the script is getting ended. The command
is ./wcsadmin.sh start --> this is used to start the processes of my
application in remote server
Please find the below code snippet of my ruby script:
Net::SSH.start(host, username, :password => password) do |ssh|
puts 'before exit'
output = ssh.exec!(/opt/wcsadmin.sh start)
puts 'Executed command'
The output of the command when i do it manually is :
[root#test bin]# ./wcsadmin.sh start
Starting Network Control System...
This may take a few minutes... stty: standard input: Invalid argument
Network Control System started successfully.
Starting SAM daemon... Done. Starting DA daemon... Starting DA syslog
daemon... start
if i use ssh.exec('./wcsadmin.sh start') the only difference is the
above output is getting printed but still the program is never ended.I
need to manually end it by hitting ctrl+c. When i searched in google i
could find you can use
nohup command('nohup /opt/wcsadmin.sh start >/tmp/teststartserver.log 2>&1')
to skip the hangup signals and tried the same.This also writes the output to teststartserver.log but
getting hanged.Can anyone please help me out on this issue?
Thanks in Advance!
Thanks, Meena
If the command itself doesn't return right away, then SSH.exec! will block further execution until the command returns. If for some reason you lose remote contact, then SSH.exec! may not know that you have lost connectivity and it will continue to block.
You could try putting the command in the background:
output = ssh.exec!('/opt/wcsadmin.sh start &')
Or maybe look at the documentation on that command and maybe it has some sort of --no-wait option that will allow it to return immediately, even if it is still working.
I have a master-workers architecture where the number of workers is growing on a weekly basis. I can no longer be expected to ssh or remote console into each machine to kill the worker, do a source control sync, and restart. I would like to be able to have the master place a message out on the network that tells each machine to sync and restart.
That's where I hit a roadblock. If I were using any sane platform, I could just do:
exec('ruby', __FILE__)
...and be done. However, I did the following test:
p Process.pid
sleep 1
exec('ruby', __FILE__)
...and on Windows, I get one ruby instance for each call to exec. None of them die until I hit ^C on the window in question. On every platform I tried this on, it is executing the new version of the file each time, which I have verified this by making simple edits to the test script while the test marched along.
The reason I'm printing the pid is to double-check the behavior I'm seeing. On windows, I am getting a different pid with each execution - which I would expect, considering that I am seeing a new process in the task manager for each run. The mac is behaving correctly: the pid is the same for every system call and I have verified with dtrace that each run is trigging a call to the execve syscall.
So, in short, is there a way to get a windows ruby script to restart its execution so it will be running any code - including itself - that has changed during its execution? Please note that this is not a rails application, though it does use activerecord.
After trying a number of solutions (including the one submitted by Byron Whitlock, which ultimately put me onto the path to a satisfactory end) I settled upon:
IO.popen("start cmd /C ruby.exe #{$0} #{ARGV.join(' ')}")
sleep 5
I found that if I didn't sleep at all after the popen, and just exited, the spawn would frequently (>50% of the time) fail. This is not cross-platform obviously, so in order to have the same behavior on the mac:
IO.popen("xterm -e \"ruby blah blah blah\"&")
The classic way to restart a program is to write another one that does it for you. so you spawn a process to restart.exe <args>, then die or exit; restart.exe waits until the calling script is no longer running, then starts the script again.