summaryrefslogtreecommitdiff
path: root/scripts/update-rcconf
blob: 4e32b30405da8b77a12aec3959e673e0cc2a9208 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# This file is part of the OpenADK project. OpenADK is copyrighted
# material, please see the LICENCE file in the top-level directory.

topdir=$(readlink -nf $(dirname $0)/.. 2>/dev/null || (cd $(dirname $0)/..; pwd -P))
. $topdir/.config

suffix=${ADK_TARGET_SYSTEM}
if [ ! -z ${ADK_TARGET_ENDIAN_SUFFIX} ];then
	suffix=${suffix}${ADK_TARGET_ENDIAN_SUFFIX}
fi
if [ ! -z ${ADK_TARGET_LIBC} ];then
	suffix=${suffix}_${ADK_TARGET_LIBC}
fi
if [ ! -z ${ADK_TARGET_CPU_TYPE} ];then
	suffix=${suffix}_${ADK_TARGET_CPU_TYPE}
fi
if [ ! -z ${ADK_TARGET_FLOAT} ];then
	suffix=${suffix}_${ADK_TARGET_FLOAT}
fi
if [ ! -z ${ADK_TARGET_ABI} ];then
	suffix=${suffix}_${ADK_TARGET_ABI}
fi

rcconf=$(ls $topdir/root_${suffix}/etc/rc.conf)

if [ ! -f $rcconf ];then
	exit 0
fi

for service in $(grep ^ADK_RUNTIME_START_ $topdir/.config |grep -v ADK_RUNTIME_START_SERVICES);do
	rcname=$(echo $service|sed -e "s#ADK_RUNTIME_START_##")
	mode=$(echo $rcname|cut -d \= -f 2)
	rcname=$(echo $rcname| sed -e "s#=.*##")
	rcname=$(echo $rcname| sed -e "s#^BUSYBOX_##")
	rcname=$(echo $rcname| tr '[:upper:]' '[:lower:]')
	# workarounds where package name not equal to service name
	if [ $rcname = "alsa_utils" ];then
		rcname=amixer
	fi
	if [ $rcname = "iptables" ];then
		rcname=firewall
	fi
	if [ $rcname = "openssh_server" ];then
		rcname=openssh
	fi
	if [ $mode = "m" ]; then
	  sed -i -e "s#^$rcname=\"NO\"#$rcname=\"DAEMON\"#" $rcconf
	else
	  sed -i -e "s#^$rcname=\"NO\"#$rcname=\"YES\"#" $rcconf
	fi
done