Last active
October 17, 2015 02:49
-
-
Save JosiahKerley/0009423d597aa1987c1f to your computer and use it in GitHub Desktop.
Autologon tool for RHEL 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ ! -d ~/.autologon ] | |
then | |
mkdir -p ~/.autologon | |
fi | |
if [ "$1" == "enable" ] | |
then | |
cat /lib/systemd/system/[email protected] > ~/.autologon/lastexec | |
sed -i '/^ExecStart/s/ExecStart.*/ExecStart=-\/sbin\/agetty --autologin root --noclear %I/' /lib/systemd/system/[email protected] | |
if [ ! "$2" == "" ] | |
then | |
echo "#!/bin/bash" > ~/.autologon/runonce | |
echo "$2" >> ~/.autologon/runonce | |
echo 'sed -i "/~\/.autologon\/runonce/d" ~/.bashrc' >> ~/.autologon/runonce | |
echo 'rm -- "$0"' >> ~/.autologon/runonce | |
chmod +x ~/.autologon/runonce | |
sed -i '/~\/.autologon\/runonce/d' ~/.bashrc | |
echo '~/.autologon/runonce' >> ~/.bashrc | |
fi | |
elif [ "$1" == "disable" ] | |
then | |
cat ~/.autologon/lastexec > /lib/systemd/system/[email protected] | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment