enable_rc.local.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. if ! [ -f /etc/rc.local ]
  3. then
  4. cat <<'EOF'>>/tmp/rc.local
  5. #!/bin/bash
  6. exit 0
  7. EOF
  8. sudo cp /tmp/rc.local /etc/
  9. sudo chmod +x /etc/rc.local
  10. sudo systemctl disable rc-local >/dev/null 2>&1
  11. sudo systemctl disable rc.local >/dev/null 2>&1
  12. fi
  13. if ! [ -f /lib/systemd/system/rc-local.service ]
  14. then
  15. cat <<'EOF'>> /tmp/rc-local.service
  16. # This file is part of systemd.
  17. #
  18. # systemd is free software; you can redistribute it and/or modify it
  19. # under the terms of the GNU Lesser General Public License as published by
  20. # the Free Software Foundation; either version 2.1 of the License, or
  21. # (at your option) any later version.
  22. # This unit gets pulled automatically into multi-user.target by
  23. # systemd-rc-local-generator if /etc/rc.local is executable.
  24. [Unit]
  25. Description=/etc/rc.local Compatibility
  26. ConditionFileIsExecutable=/etc/rc.local
  27. After=network.target
  28. [Service]
  29. Type=forking
  30. ExecStart=/etc/rc.local start
  31. TimeoutSec=0
  32. RemainAfterExit=yes
  33. GuessMainPID=no
  34. EOF
  35. sudo cp /tmp/rc-local.service /lib/systemd/system/rc-local.service
  36. sudo systemctl daemon-reload >/dev/null 2>&1
  37. fi