summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Tringali <tringalinvent@libero.it>2019-01-19 14:41:09 +0100
committerLuca Tringali <tringalinvent@libero.it>2019-01-19 14:41:09 +0100
commit4c8de2f02ce8b8252a41c0246705778d90adb389 (patch)
tree7778c344f77295055900571a92751cd2e8d87b3a
parente1f70fc868aff90177c772a132905f3c5e747162 (diff)
Autologin and run on Raspberry
-rw-r--r--autologin.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/autologin.sh b/autologin.sh
new file mode 100644
index 0000000..939b57a
--- /dev/null
+++ b/autologin.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+username="pi"
+cat <<EOF > /etc/systemd/system/tty1.service
+[Service]
+Type=simple
+ExecStart=/sbin/getty -a pi 38400 tty1
+StandardInput=tty
+StandardOutput=tty
+TTYPath=/dev/tty1
+TTYReset=yes
+Restart=always
+[Install]
+WantedBy=multi-user.target
+EOF
+
+systemctl enable tty1.service
+systemctl start tty1.service
+
+cat <<EOF > /home/$username/.xinitrc
+#! /bin/bash
+cat
+EOF
+chown $username:$username /home/$username/.xinitrc
+
+cat <<EOF > /home/$username/.bashrc
+if [ \$(tty | sed s:^/dev/::) == "tty1" ]; then
+export DISPLAY=:0
+/home/$username/appstart &
+startx
+fi
+EOF
+chown $username:$username /home/$username/.bashrc
+
+cat <<EOF > /home/$username/appstart
+#! /bin/bash
+
+# Wait a second for X server to start:
+sleep 1
+# use this if Xorg starts on tty7
+# sudo chvt 7
+/usr/bin/python3 /home/$username/termostato-raspberry/termostato.py
+EOF
+chmod +x /home/$username/appstart
+chown $username:$username /home/$username/appstart
+
+sudo systemctl disable sddm.service
+sudo usermod -a -G tty $username
+sudo usermod -a -G video $username