Fionn Posted July 2, 2020 Share Posted July 2, 2020 Armbianmonitor: http://ix.io/2qHA Hi, I am having a strange problem with my Orangepi One, I previously had a python script which was run on login using .bashrc. The python script controlled VLC using the python bindings and hence I could not use crontab -e or rc.local as they are run in the backgound. Previously .bashrc worked without any issues however either I updated VLC or armbian and now it does not run after I login (even using an autologin). Strangely enough however if I login via SSH the script runs. To access it I use : sudo nano /home/user/.bashrc To run the script I append to the end of the file without making any adjustments: echo Running tv streaming program from boot python3 /home/user/path_to_file/pyVLC.py It seems strange as the program runs successfully when I login with SSH, which makes me think that maybe I need to specify that it runs in normal start-up or that perhaps there is something running before it that blocks it (maybe the armbian logo as it is not present in the ssh boot?). I have reloaded the OS to see if I accidentally changed a setting however the same problem is occurring. The only changes that are made from the fresh boot were installing: python3 cython chromium chromedriver and enabling SSH from armbian-monitor I am unsure how to proceed and any assistance would be greatly appreciated. Best regards, Link to comment Share on other sites More sharing options...
lanefu Posted July 3, 2020 Share Posted July 3, 2020 Not running when you login to text console? Desktop? Link to comment Share on other sites More sharing options...
Fionn Posted July 3, 2020 Author Share Posted July 3, 2020 (edited) Yes the text console, I haven't installed the desktop. Edited July 3, 2020 by Fionn Link to comment Share on other sites More sharing options...
xwiggen Posted July 4, 2020 Share Posted July 4, 2020 13 hours ago, Fionn said: Yes the text console, I haven't installed the desktop. How do you autologin with user? Link to comment Share on other sites More sharing options...
Fionn Posted July 5, 2020 Author Share Posted July 5, 2020 I went to the folder: /lib/systemd/system/getty@tty1.service.d/ the created a file: 20-autologin.conf after which I wrote: [Service] ExecStart= ExecStart=-/sbin/agetty --autologin user --noclear %I $TERM where user is the name of the profile which is logging in Link to comment Share on other sites More sharing options...
xwiggen Posted July 6, 2020 Share Posted July 6, 2020 Try updating 20-autologin; [Unit] ... Wants=graphical.target After=graphical.target ... Link to comment Share on other sites More sharing options...
Fionn Posted July 7, 2020 Author Share Posted July 7, 2020 23 hours ago, xwiggen said: Try updating 20-autologin; [Unit] ... Wants=graphical.target After=graphical.target ... Thanks for the help, I tried this but no luck. I also tried booting as root using mkdir -p /etc/systemd/system/getty@tty1.service.d cat << _EOF_ > /etc/systemd/system/getty@tty1.service.d/autologin.conf [Service] ExecStart= ExecStart=-/sbin/agetty --autologin root %I _EOF_ systemctl daemon-reload which I found here: Unfortunatly I'm still having the same problem, I have also tried without autologin but the same issue, the bashrc script runs but only from ssh. This is making me think that the issue is to do with the way I've setup .bashrc. Perhaps someone verify that this is correct: To set up a program to run on login using .bashrc you; 1. login to the user which will be running the script. In this case I'll refer to it as "example_user". 2. enter the .bashrc file by entering: "sudo nano /home/example_user/.bashrc" 3. to run the script go to the end of the file and enter the program you wish to run. In this case "python3 /path_to_file/example_file.py" << In my case sudo isn't needed to run the file. The end of the resulting file should then look like: " # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). if ! shopt -oq posix; then if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion elif [ -f /etc/bash_completion ]; then . /etc/bash_completion fi fi echo Running tv streaming program from boot python3 /path_to_file/example.py " Link to comment Share on other sites More sharing options...
xwiggen Posted July 8, 2020 Share Posted July 8, 2020 On 7/7/2020 at 1:19 PM, Fionn said: Unfortunatly I'm still having the same problem, I have also tried without autologin but the same issue, the bashrc script runs but only from ssh. This is making me think that the issue is to do with the way I've setup .bashrc. bashrc is supposed to be for interactive uses, I don't really know how getty interpretes this and it's difficult debugging from another end. Anyhow, the best/conventional method to do what you want is by writing a systemd service such as https://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/, which basically describes your usecase though omits User= specification. Link to comment Share on other sites More sharing options...
Fionn Posted July 8, 2020 Author Share Posted July 8, 2020 Thank you for the suggestion! Out of frustration I flashed the sd and installed a fresh version of armbian buster and was able to get the .bashrc file to run without any issues. The only thing is the video which is being streamed with the program isn't running as well as it was before so perhaps there was something installed relating to vlc which caused the initial issue. I am going to attempt to use the systemd method you mentioned, as I cannot seem to get the video working smoothly on the new installation. Link to comment Share on other sites More sharing options...
Recommended Posts