Autologin & Autostart bash scripts on Debian 8 Jessie (systemd) for server use
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Autologin & Autostart bash scripts on Debian 8 Jessie (systemd) for server use
Perhaps this should have been in Linux - General... For tl;dr, read bold paragraph:
I have a virtual machine that runs Debian 8, and I have configured it to not start X server and boot into a terminal window. So far we are good.
But, I have 3 game servers that I want to run on the same computer (mcserver, tf2server and an FTB minecraft server).
Since I didn't have terminal tabs like in a Desktop Environment, I decided to use tty2-tty4 to run each server independently (so I can quickly switch to each tty and access each server's console at will)
I can do this very easily manually, but since the host computer has frequent restarts I wanted to set it up so it auto logins to 4 seperate accounts on each tty1-4 (jason, mcserver, tf2server and ftbserver respectively) automatically and then runs the servers (all of which are bash scripts).
This is where I run into issues. I have tried tmux with multiple windows running seperate commands, I have tried modifying files in /etc/ and accidentally locked myself out and had to resort to GRUB rescue terminal, and I have tried writing many bash scripts and trying to get them to auto run but failed.
Maybe I don't even need to autologin to the 4 terminals like I want, but what I do want is:
I want run 3 different bash scripts (2 of which have a y/n prompt that I need make the computer automatically answer yes (the "y" on the prompt is already typed in, all that is needed is for ENTER to be pressed)) on tty2-tty4 every time I start my computer, and as a consequence I believe I need to login to 3 different accounts on tty2 through tty4.
I'll be honest, I am not familiar with how to autostart things on particular tty's, but thinking about your problem perhaps a tabbed terminal with four different ssh sessions into your server would be a more elegant solution? That way, you can just click on the various tabs to access the desired session, or you can even pull off tabs so you can view multiple sessions side-by-side.
Assuming the computer with the tabbed terminal doesn't have frequent reboots (why do you have frequent reboots?), you can set up each session with a command like:
Code:
ssh debianvm "mcserverscript"
After a reboot of the debian VM, you just press UP-ARROW and then ENTER in each of the tabs to reconnect and start the server scripts. If you want to get really fancy, you can set up a script on a loop which will automatically try and reconnect via ssh and run the script. In other words, the VM itself doesn't have any automation to start anything upon reboot. Rather, the computer with the tabbed terminal has scripts which will frequently attempt to reconnect and restart the scripts if the ssh session is disconnected.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.