.automated_script.sh 788 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. script_cmdline ()
  3. {
  4. local param
  5. for param in $(< /proc/cmdline); do
  6. case "${param}" in
  7. script=*) echo "${param##*=}" ; return 0 ;;
  8. esac
  9. done
  10. }
  11. automated_script ()
  12. {
  13. local script rt
  14. script="$(script_cmdline)"
  15. if [[ -n "${script}" && ! -x /tmp/startup_script ]]; then
  16. if [[ "${script}" =~ ^http:// || "${script}" =~ ^ftp:// ]]; then
  17. wget "${script}" --retry-connrefused -q -O /tmp/startup_script >/dev/null
  18. rt=$?
  19. else
  20. cp "${script}" /tmp/startup_script
  21. rt=$?
  22. fi
  23. if [[ ${rt} -eq 0 ]]; then
  24. chmod +x /tmp/startup_script
  25. /tmp/startup_script
  26. fi
  27. fi
  28. }
  29. if [[ $(tty) == "/dev/tty1" ]]; then
  30. automated_script
  31. fi