Переглянути джерело

Startup script now boots correctly

Laurent HUBERT 6 роки тому
батько
коміт
4be153ab36
3 змінених файлів з 11 додано та 9 видалено
  1. 2 8
      deploy
  2. 7 1
      first-boot-init.service
  3. 2 0
      first-boot-script

+ 2 - 8
deploy

@@ -19,16 +19,10 @@ cp scripts/* $FIRST_BOOT_SCRIPTS_DIR
 touch $FIRST_BOOT_BASE_DIR/.mustrun
 
 # Deploys
-#See to make automatic root at first login https://serverfault.com/questions/760391/make-no-password-required-on-local-linux-tty-login
-cp /root/.profile /root/.profile.firstboot
-grep -F "$FIRST_BOOT_BASE_DIR" /root/.profile > /dev/null || echo $FIRST_BOOT_BASE_DIR/first-boot-script >> /root/.profile
-
-the_user=$(id -u 1000 -n)
-cp /home/$the_user/.profile /home/$the_user/.profile.firstboot
-grep -F "$FIRST_BOOT_BASE_DIR" /home/$the_user/.profile > /dev/null || echo sudo $FIRST_BOOT_BASE_DIR/first-boot-script >> /home/$the_user/.profile
-
+#https://unix.stackexchange.com/questions/265014/how-to-start-a-script-on-tty-instead-of-asking-for-login-in-systemd
 #https://stackoverflow.com/questions/14152026/how-can-i-automatically-login-on-a-tty-and-execute-a-script
 #https://unix.stackexchange.com/questions/401759/automatically-login-on-debian-9-2-1-command-line
+systemctl enable first-boot-init.service
 
 echo "You can now run rm -r on this directory"
 echo "e.g. :"

+ 7 - 1
first-boot-init.service

@@ -1,10 +1,16 @@
 [Unit]
-Description=yourscript
+Description=First boot procedure
 ConditionPathExists=/etc/first-boot/.mustrun
+After=getty.target
+Conflicts=getty@tty1.service
 
 [Service]
 Type=oneshot
+RemainAfterExit=yes
 ExecStart=/etc/first-boot/first-boot-script
+StandardInput=tty-force
+StandardOutput=inherit
+StandardError=inherit
 
 [Install]
 WantedBy=multi-user.target

+ 2 - 0
first-boot-script

@@ -30,4 +30,6 @@ do
 done
 
 rm $FIRST_BOOT_BASE_DIR/.mustrun
+systemctl disable first-boot-init.service
+
 exit 0