update-rcconf 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/usr/bin/env bash
  2. # This file is part of the OpenADK project. OpenADK is copyrighted
  3. # material, please see the LICENCE file in the top-level directory.
  4. topdir=$(readlink -nf $(dirname $0)/.. 2>/dev/null || (cd $(dirname $0)/..; pwd -P))
  5. host=$(gcc -dumpmachine)
  6. case :$PATH: in
  7. (*:$topdir/host_$host/usr/bin:*) ;;
  8. (*) export PATH=$topdir/host_$host/usr/bin:$PATH ;;
  9. esac
  10. . $topdir/.config
  11. suffix=${ADK_TARGET_SYSTEM}
  12. if [ ! -z ${ADK_TARGET_LIBC} ];then
  13. suffix=${suffix}_${ADK_TARGET_LIBC}
  14. fi
  15. if [ ! -z ${ADK_TARGET_CPU_TYPE} ];then
  16. suffix=${suffix}_${ADK_TARGET_CPU_TYPE}
  17. fi
  18. if [ ! -z ${ADK_TARGET_ENDIAN_SUFFIX} ];then
  19. suffix=${suffix}${ADK_TARGET_ENDIAN_SUFFIX}
  20. fi
  21. if [ ! -z ${ADK_TARGET_FLOAT} ];then
  22. suffix=${suffix}_${ADK_TARGET_FLOAT}
  23. fi
  24. if [ ! -z ${ADK_TARGET_ABI} ];then
  25. suffix=${suffix}_${ADK_TARGET_ABI}
  26. fi
  27. if [ ! -z ${ADK_TARGET_BINFMT} ];then
  28. suffix=${suffix}_${ADK_TARGET_BINFMT}
  29. fi
  30. rcconf=$(ls $topdir/root_${suffix}/etc/rc.conf)
  31. if [ ! -f $rcconf ];then
  32. exit 0
  33. fi
  34. for service in $(grep ^ADK_RUNTIME_START_ $topdir/.config |grep -v ADK_RUNTIME_START_SERVICES);do
  35. rcname=$(echo $service|sed -e "s#ADK_RUNTIME_START_##")
  36. mode=$(echo $rcname|cut -d \= -f 2)
  37. rcname=$(echo $rcname| sed -e "s#=.*##")
  38. rcname=$(echo $rcname| sed -e "s#^BUSYBOX_##")
  39. rcname=$(echo $rcname| tr '[:upper:]' '[:lower:]')
  40. # workarounds where package name not equal to service name
  41. if [ $rcname = "alsa_utils" ];then
  42. rcname=amixer
  43. fi
  44. if [ $rcname = "iptables" ];then
  45. rcname=firewall
  46. fi
  47. if [ $rcname = "nfs_utils_server" ];then
  48. rcname=nfsd
  49. fi
  50. if [ $rcname = "openssh_server" ];then
  51. rcname=openssh
  52. fi
  53. if [ $mode = "m" ]; then
  54. sed -i -e "s#^$rcname=\"NO\"#$rcname=\"DAEMON\"#" $rcconf
  55. else
  56. sed -i -e "s#^$rcname=\"NO\"#$rcname=\"YES\"#" $rcconf
  57. fi
  58. done