update-rcconf 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. os=$(uname)
  5. if [ "$os" = "Darwin" ]; then
  6. sed="sed -i '' -e"
  7. else
  8. sed="sed -i -e"
  9. fi
  10. topdir=$(readlink -nf $(dirname $0)/.. 2>/dev/null || (cd $(dirname $0)/..; pwd -P))
  11. . $topdir/.config
  12. suffix=${ADK_TARGET_SYSTEM}
  13. if [ ! -z ${ADK_TARGET_LIBC} ];then
  14. suffix=${suffix}_${ADK_TARGET_LIBC}
  15. fi
  16. if [ ! -z ${ADK_TARGET_CPU_TYPE} ];then
  17. suffix=${suffix}_${ADK_TARGET_CPU_TYPE}
  18. fi
  19. if [ ! -z ${ADK_TARGET_ENDIAN_SUFFIX} ];then
  20. suffix=${suffix}${ADK_TARGET_ENDIAN_SUFFIX}
  21. fi
  22. if [ ! -z ${ADK_TARGET_FLOAT} ];then
  23. suffix=${suffix}_${ADK_TARGET_FLOAT}
  24. fi
  25. if [ ! -z ${ADK_TARGET_ABI} ];then
  26. suffix=${suffix}_${ADK_TARGET_ABI}
  27. fi
  28. if [ ! -z ${ADK_TARGET_BINFMT} ];then
  29. suffix=${suffix}_${ADK_TARGET_BINFMT}
  30. fi
  31. rcconf=$(ls $topdir/root_${suffix}/etc/rc.conf)
  32. if [ ! -f $rcconf ];then
  33. exit 0
  34. fi
  35. for service in $(grep ^ADK_RUNTIME_START_ $topdir/.config |grep -v ADK_RUNTIME_START_SERVICES);do
  36. rcname=$(echo $service|sed -e "s#ADK_RUNTIME_START_##")
  37. mode=$(echo $rcname|cut -d \= -f 2)
  38. rcname=$(echo $rcname| sed -e "s#=.*##")
  39. rcname=$(echo $rcname| sed -e "s#^BUSYBOX_##")
  40. rcname=$(echo $rcname| tr '[:upper:]' '[:lower:]')
  41. # workarounds where package name not equal to service name
  42. if [ $rcname = "alsa_utils" ];then
  43. rcname=amixer
  44. fi
  45. if [ $rcname = "iptables" ];then
  46. rcname=firewall
  47. fi
  48. if [ $rcname = "nfs_utils_server" ];then
  49. rcname=nfsd
  50. fi
  51. if [ $rcname = "openssh_server" ];then
  52. rcname=openssh
  53. fi
  54. if [ $mode = "m" ]; then
  55. $sed "s#^$rcname=\"NO\"#$rcname=\"DAEMON\"#" $rcconf
  56. else
  57. $sed "s#^$rcname=\"NO\"#$rcname=\"YES\"#" $rcconf
  58. fi
  59. done