Polybar launch.sh not running when Awesome wm is restarted - sh

I've been setting up my Linux desktop, running Arch on Kernel 5.18.14, and have run into some issues when configuring Polybar to start when Awesome wm starts
This is my polybar launch script (/home/user/.config/polybar/launch.sh):
#!/bin/bash
killall -q polybar
while pgrep -x polybar >/dev/null; do sleep 1; done
for m in $(polybar --list-monitors | cut -d":" -f1); do
MONITOR=$m polybar duat &
done
My polybar bar is named duat in the config.ini
This is where I execute the script in my Awesome wm rc.lua
awful.spawn.with_shell("/home/user/.config/polybar/launch.sh")
awful.spawn.with_shell("feh --bg-fill ~/.config/awesome/backgrounds/background.png")
awful.spawn.with_shell("wal -R")
Any help is greatly appreciated. It should be noted that once I run the script manually, awesome wm seems to have no problem running the script when reloaded, but if polybar is completely inactive, it refuses to start.

Related

Can Raspberry pi run 2 commands on startup with a delay in between them

I want to fire 2 commands on startup on my raspberry pi
The first one runs a node server starting script.
The second one should open chromium browser with a specific page.
The point is that I want to wait a couple of seconds to launch chromium so I'm sure that the webpage will be connected to the node server.
I tried so many things but I can't seem to fix a the delay.
Any suggestions?
This is what I have now in an LXDE session:
#lxpanel --profile LXDE-pi
#pcmanfm --desktop --profile LXDE-pi
#xscreensaver -no-splash
// This starts the node server
#/home/pi/autostart.sh
// This starts the browser
#/home/pi/async.sh
The async bash runs this:
#!/usr/bin/env bash
sleep 5
chromium-browser -kiosk http://localhost:3000
You start the node server and loop until the site comes online before launching the web-browser.
Replace "sleep 5" in async.sh by the following:
until $(curl --output /dev/null --silent --head --fail http://localhost:3000); do
printf '.'
sleep 1
done
source : How to create a loop in bash that is waiting for a webserver to respond?

Start shrew vpn client (iked & ikec) on start-up of OSMC on Raspberry 2

I would like to connect to a VPN on start-up of OSMC.
Environment:
installed OSMC on Raspberry 2
downloaded, compiled and installed shrew soft vpn on the device
As user 'osmc' with ssh
> sudo iked starts the daemon successfully
> ikec -r "test.vpn" -a starts the client, loads the config and connects successfully
rc.local:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
sudo iked >> /home/osmc/iked.log 2>> /home/osmc/iked.error.log &
ikec -a -r "test.vpn" >> /home/osmc/ikec.log 2>> /home/osmc/ikec.error.log &
exit 0
after start of raspberry iked is as process visible with ps -e
but ikec is not running
osmc#osmc:~$ /etc/rc.local starts the script and connects to vpn successfully
Problem:
Why does the script not working correctly on start-up?
Thank you for your help!
I was also looking to do the same thing as you and ran into the same problem. I'm no linux expert, but I did figure out a workaround.
I created a script called ikec_after_reboot.sh and it looks like this...
$ cat ikec_after_reboot.sh
#!/bin/bash
echo "Starting ikec"
ikec -r test.vpn -a
I then installed cron.
sudo apt-get update
sudo apt-get install cron
Edit the cron job as root and run the ikec script 60 seconds after reboot.
sudo crontab -e
SHELL=/bin/bash
#reboot sleep 60 && /home/osmc/ikec_after_reboot.sh & >> /home/osmc/ikec.log 2>&1
Now edit your /etc/rc.local file and add the following.
sudo iked >> //home/osmc/iked.log 2>> /home/osmc/iked.error.log &
exit 0
Hopefully, this is helpful to you.

How to run script in Solaris after boot once

I looking for the right way to run shell script first boot Solaris.
I need to run resize command, there is a my script
#!/bin/sh -ux
echo "#!/bin/sh -ux" > /etc/rc3.d/S90scale
echo "/sbin/zpool set autoexpand=on rpool" >> /etc/rc3.d/S90scale
echo "/sbin/zpool online -e rpool c1d0" >> /etc/rc3.d/S90scale
echo "rm /etc/rc3.d/S90scale" >> /etc/rc3.d/S90scale
echo "/sbin/shutdown -y -i6 -g0" >> /etc/rc3.d/S90scale
chmod a+x /etc/rc3.d/S90scale
actually script working properly, but unfortunately resize do not work. When I do the same things from user session everything just fine.
What exactly I doing wrong?
Your method is not the "right" one to run a script once after boot as it uses the legacy approach. The correct way would be to create an smf service that runs once. However, it does work anyway with Solaris 10 and 11 as the rc scripts while deprecated are still processed so I won't elaborate more about smf.
The main issue is you don't check for errors and whatever happens, it remove the script and reboot preventing any analysis to occur.
I would suggest to modify your script to log what is happening in a file and quit on error:
#!/bin/ksh
cat > /etc/rc3.d/S90scale <<%EOF%
exec > /var/tmp/S90scale.log 2>&1 # logs everything to file
set -xe # show commands and exits on error
/sbin/zpool set autoexpand=on rpool
/sbin/zpool online -e rpool c1d0
mv /etc/rc3.d/S90scale /etc/rc3.d/_S90scale
/sbin/shutdown -y -i6 -g0
%EOF%
chmod a+x /etc/rc3.d/S90scale
After the next reboot complete, you should have a look to the /var/tmp/S90scale.log file and possibly see an error message there.

redhat linux upstart (initctl) issue on reboot

Morning,
I have monit I am testing on redhat 6.4 system. I setup a /etc/init/monit.conf:
description "Monit service manager"
limit core unlimited unlimited
start on runlevel [2345]
stop on runlevel [!2345]
expect daemon
respawn
exec /local/mis/monit/bin/monit -c /local/mis/monit/etc/monitrc
pre-stop exec /local/mis/monit/bin/monit -c /local/mis/monit/etc/monitrc quit
At the command line as root I can run stop monit and start monit just fine and it shows pid number. However, during reboot, it does not start. It shows start/running with no pid if I run initctl list, but if you check with ps -ef monit is not running. I can run stop monit and then run start monit just fine after a reboot. I am at a lose with how to troubleshoot. My system has /var/log/messages, but no /var/log/syslog. I see options to use log-priority info, but I am not sure how to set that as the level for logging during the reboot. The /var/log/message does not mention monit and /var/log/boot.log does not either. dmesg shows nothing.
this sounds like the same problem we just fixed.
We run monit as user "monit". upstart was trying to start it as root and the monit files where owned my user "monit". And we were getting identical symptoms you were getting.
To fix it i altered /etc/init/monit to
exec su -c "/web/bin/monit -c /web/etc/monitrc" monit
now when i start monitI see::
# start monit
monit start/running, process 3421
The final solution I ended up using: description "Monit service manager"
start on (net-device-up IFACE=eth0 and started networking and runlevel [2345])
stop on runlevel [!2345]
limit core unlimited unlimited
expect daemon
respawn
Had to do a pre-start script to loop until successful with nslookup of mail server listed in the monitrc file.
pre-start script
while [ 0 ]; do
i=/usr/bin/nslookup outlookwebapp.na.sas.com | grep Name
if [ ! -z "$i" ]; then
break
fi
sleep 4
done
end script
exec /local/mis/monit/bin/monit -c /local/mis/monit/etc/monitrc
pre-stop exec /local/mis/monit/bin/monit -c /local/mis/monit/etc/monitrc quit

VLC won't start automatically at Ubuntu boot

I am trying to configure VLC to start streaming two streams automatically on boot with Upstart.
Here is my upstart script:
description "VLC streams"
start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [016]
exec /home/streamer/stream.sh
and stream.sh:
#!/bin/bash
cvlc -v "/home/administrator/Videos/Kastiel/kastiel.xspf" --sout '#std{access=udp{ttl=2},mux=ts,dst=239.220.220.31:9200}' --sout-keep --loop &
cvlc -v "/home/administrator/Videos/Rozpravky/rozpravky.xspf" --sout '#std{access=udp{ttl=2},mux=ts,dst=239.220.220.2:9200}' --sout-keep --random &
exit 0
However, after the computer boots, there is no stream and VLC process is not running. When I run stream.sh manually, it works with no problem.
Does anybody know what mistake am I doing?
I am using Ubuntu 12.10 and VLC 2.0.5.
Thank you in advance for any help.
Milan
Vlc doesn't support to be run as root due to security reasons.
You should use sudo -u user in script to change the user.
try as :
sudo -u username cvlc -v "/home/administrator/Videos/Kastiel/kastiel.xspf" --sout '#std{access=udp{ttl=2},mux=ts,dst=239.220.220.31:9200}' --sout-keep --loop &