developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 1 | require recipes-ccsp/ccsp/ccsp_common_turris.inc |
| 2 | |
| 3 | DEPENDS_append = " kernel-autoconf utopia-headers libsyswrapper telemetry" |
| 4 | |
| 5 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 6 | |
| 7 | EXTRA_OECONF_append = " --with-ccsp-arch=arm" |
| 8 | |
| 9 | SRC_URI_append = " \ |
| 10 | file://0001-fix-lan-handler-for-turris.patch;apply=no \ |
| 11 | file://0003-remove-autoconf.patch;apply=no \ |
| 12 | file://system_defaults \ |
| 13 | " |
| 14 | SRC_URI_append_dunfell = "file://0001-Work-around-for-brlan0-issue.patch;apply=no" |
| 15 | |
| 16 | SRC_URI += "file://posix-gwprovapp.patch;apply=no" |
| 17 | #This patch will add dummy swctl api which is originally given by brcm for XB3. |
| 18 | SRC_URI += "file://0002-fix-swctl-missing-api.patch;apply=no" |
| 19 | SRC_URI += "file://firewall-secure-onboard.patch;apply=no" |
| 20 | SRC_URI += "file://dhcp_script.sh" |
| 21 | |
| 22 | LDFLAGS_append = " \ |
| 23 | -lsecure_wrapper \ |
| 24 | " |
| 25 | |
| 26 | CFLAGS_append = " -Wno-format-extra-args -Wno-error " |
| 27 | CFLAGS_append += "${@bb.utils.contains('DISTRO_FEATURES', 'rdkb_wan_manager', ' -D_WAN_MANAGER_ENABLED_', '', d)}" |
| 28 | |
| 29 | # we need to patch to code for Turris |
| 30 | do_turris_patches() { |
| 31 | cd ${S} |
| 32 | if [ ! -e turris_patch_applied ]; then |
| 33 | bbnote "Patching 0001-fix-lan-handler-for-turris.patch" |
| 34 | patch -p1 < ${WORKDIR}/0001-fix-lan-handler-for-turris.patch |
| 35 | |
| 36 | bbnote "Patching posix-gwprovapp.patch" |
| 37 | patch -p1 < ${WORKDIR}/posix-gwprovapp.patch |
| 38 | |
| 39 | bbnote "Patching 0002-fix-swctl-missing-api.patch" |
| 40 | patch -p1 < ${WORKDIR}/0002-fix-swctl-missing-api.patch |
| 41 | |
| 42 | bbnote "Patching firewall-secure-onboard.patch" |
| 43 | patch -p1 < ${WORKDIR}/firewall-secure-onboard.patch || echo "ERROR or Patch already applied" |
| 44 | |
| 45 | touch turris_patch_applied |
| 46 | fi |
| 47 | } |
| 48 | |
| 49 | do_turris_patches-append_dunfell() { |
| 50 | cd ${S} |
| 51 | if [ ! -e dunfell_turris_patch_applied ]; then |
| 52 | patch -p1 < ${WORKDIR}/0001-Work-around-for-brlan0-issue.patch |
| 53 | fi |
| 54 | touch dunfell_turris_patch_applied |
| 55 | } |
| 56 | |
| 57 | addtask turris_patches after do_unpack before do_compile |
| 58 | |
| 59 | do_install_append() { |
| 60 | |
| 61 | # Don't install header files which are provided by utopia-headers |
| 62 | rm -f ${D}${includedir}/utctx/autoconf.h |
| 63 | rm -f ${D}${includedir}/utctx/utctx.h |
| 64 | rm -f ${D}${includedir}/utctx/utctx_api.h |
| 65 | rm -f ${D}${includedir}/utctx/utctx_rwlock.h |
| 66 | |
| 67 | # Config files and scripts |
| 68 | install -d ${D}/rdklogs |
| 69 | install -d ${D}/fss/gw/bin |
| 70 | install -d ${D}/fss/gw/usr/bin |
| 71 | install -d ${D}/fss/gw/usr/sbin |
| 72 | install -d ${D}/fss/gw/etc/utopia/service.d |
| 73 | install -d ${D}/var/spool/cron/crontabs |
| 74 | |
| 75 | install -d ${D}${sbindir}/ |
| 76 | install -d ${D}${sysconfdir}/utopia/service.d |
| 77 | install -d ${D}${sysconfdir}/utopia/registration.d |
| 78 | install -d ${D}${sysconfdir}/utopia/post.d |
| 79 | install -d ${D}${sysconfdir}/IGD |
| 80 | install -d ${D}${sysconfdir}/utopia/service.d/service_bridge |
| 81 | install -d ${D}${sysconfdir}/utopia/service.d/service_ddns |
| 82 | install -d ${D}${sysconfdir}/utopia/service.d/service_dhcp_server |
| 83 | install -d ${D}${sysconfdir}/utopia/service.d/service_lan |
| 84 | install -d ${D}${sysconfdir}/utopia/service.d/service_multinet |
| 85 | install -d ${D}${sysconfdir}/utopia/service.d/service_syslog |
| 86 | install -d ${D}${sysconfdir}/utopia/service.d/service_wan |
| 87 | |
| 88 | install -m 755 ${S}/source/scripts/init/system/utopia_init.sh ${D}${sysconfdir}/utopia/ |
| 89 | install -m 644 ${S}/source/scripts/init/defaults/system_defaults_arm ${D}${sysconfdir}/utopia/system_defaults |
| 90 | install -m 755 ${S}/source/scripts/init/service.d/*.sh ${D}${sysconfdir}/utopia/service.d/ |
| 91 | install -m 755 ${S}/source/scripts/init/service.d/service_bridge/*.sh ${D}${sysconfdir}/utopia/service.d/service_bridge |
| 92 | install -m 755 ${S}/source/scripts/init/service.d/service_ddns/*.sh ${D}${sysconfdir}/utopia/service.d/service_ddns |
| 93 | install -m 755 ${S}/source/scripts/init/service.d/service_dhcp_server/* ${D}${sysconfdir}/utopia/service.d/service_dhcp_server |
| 94 | install -m 755 ${S}/source/scripts/init/service.d/service_lan/*.sh ${D}${sysconfdir}/utopia/service.d/service_lan |
| 95 | install -m 755 ${S}/source/scripts/init/service.d/service_multinet/*.sh ${D}${sysconfdir}/utopia/service.d/service_multinet |
| 96 | install -m 755 ${S}/source/scripts/init/service.d/service_syslog/*.sh ${D}${sysconfdir}/utopia/service.d/service_syslog |
| 97 | install -m 755 ${S}/source/scripts/init/service.d/service_wan/*.sh ${D}${sysconfdir}/utopia/service.d/service_wan |
| 98 | install -m 755 ${S}/source/scripts/init/service.d/service_firewall/firewall_log_handle.sh ${D}${sysconfdir}/utopia/service.d/ |
| 99 | install -m 644 ${S}/source/igd/src/inc/*.xml ${D}${sysconfdir}/IGD |
| 100 | install -D -m 644 ${S}/source/scripts/init/syslog_conf/syslog.conf_default ${D}/fss/gw/${sysconfdir}/syslog.conf.${BPN} |
| 101 | install -m 755 ${S}/source/scripts/init/syslog_conf/log_start.sh ${D}${sbindir}/ |
| 102 | install -m 755 ${S}/source/scripts/init/syslog_conf/log_handle.sh ${D}${sbindir}/ |
| 103 | install -m 755 ${S}/source/scripts/init/syslog_conf/syslog_conf_tool.sh ${D}${sbindir}/ |
| 104 | install -m 644 ${S}/source/scripts/init/service.d/event_flags ${D}${sysconfdir}/utopia/service.d/ |
| 105 | install -m 644 ${S}/source/scripts/init/service.d/rt_tables ${D}${sysconfdir}/utopia/service.d/rt_tables |
| 106 | install -m 755 ${S}/source/scripts/init/service.d/service_cosa_arm.sh ${D}${sysconfdir}/utopia/service.d/service_cosa.sh |
| 107 | install -m 755 ${S}/source/scripts/init/service.d/service_dhcpv6_client_arm.sh ${D}${sysconfdir}/utopia/service.d/service_dhcpv6_client.sh |
| 108 | install -m 755 ${S}/source/scripts/init/system/need_wifi_default.sh ${D}${sysconfdir}/utopia/ |
| 109 | touch ${D}${sysconfdir}/dhcp_static_hosts |
| 110 | #turris omnia uses default service_bridge.sh for now |
| 111 | install -m 755 ${S}/source/scripts/init/service.d/service_bridge.sh ${D}${sysconfdir}/utopia/service.d/service_bridge.sh |
| 112 | |
| 113 | install -m 755 ${WORKDIR}/dhcp_script.sh ${D}${sysconfdir}/ |
| 114 | #Removing service_dhcp_server.sh as dnsmasq is invoked by service_dhcp binary |
| 115 | rm ${D}${sysconfdir}/utopia/service.d/service_dhcp_server.sh |
| 116 | |
| 117 | # Creating symbolic links to install files in specific directory as in legacy builds |
| 118 | ln -sf /usr/bin/10_firewall ${D}${sysconfdir}/utopia/post.d/10_firewall |
| 119 | ln -sf /usr/bin/service_multinet_exec ${D}${sysconfdir}/utopia/service.d/service_multinet_exec |
| 120 | ln -sf /usr/bin/10_mcastproxy ${D}${sysconfdir}/utopia/post.d/10_mcastproxy |
| 121 | ln -sf /usr/bin/10_mldproxy ${D}${sysconfdir}/utopia/post.d/10_mldproxy |
| 122 | ln -sf /usr/bin/15_igd ${D}${sysconfdir}/utopia/post.d/15_igd |
| 123 | ln -sf /usr/bin/15_misc ${D}${sysconfdir}/utopia/post.d/15_misc |
| 124 | ln -sf /usr/bin/02_bridge ${D}${sysconfdir}/utopia/registration.d/02_bridge |
| 125 | ln -sf /usr/bin/02_forwarding ${D}${sysconfdir}/utopia/registration.d/02_forwarding |
| 126 | ln -sf /usr/bin/02_ipv4 ${D}${sysconfdir}/utopia/registration.d/02_ipv4 |
| 127 | ln -sf /usr/bin/02_lanHandler ${D}${sysconfdir}/utopia/registration.d/02_lanHandler |
| 128 | ln -sf /usr/bin/02_multinet ${D}${sysconfdir}/utopia/registration.d/02_multinet |
| 129 | ln -sf /usr/bin/02_wan ${D}${sysconfdir}/utopia/registration.d/02_wan |
| 130 | ln -sf /usr/bin/02_lan ${D}${sysconfdir}/utopia/registration.d/02_lan |
| 131 | ln -sf /usr/bin/15_ccsphs ${D}${sysconfdir}/utopia/registration.d/15_ccsphs |
| 132 | ln -sf /usr/bin/15_ddnsclient ${D}${sysconfdir}/utopia/registration.d/15_ddnsclient |
| 133 | ln -sf /usr/bin/15_dhcp_server ${D}${sysconfdir}/utopia/registration.d/15_dhcp_server |
| 134 | ln -sf /usr/bin/15_hotspot ${D}${sysconfdir}/utopia/registration.d/15_hotspot |
| 135 | ln -sf /usr/bin/15_ssh_server ${D}${sysconfdir}/utopia/registration.d/15_ssh_server |
| 136 | ln -sf /usr/bin/15_wecb ${D}${sysconfdir}/utopia/registration.d/15_wecb |
| 137 | ln -sf /usr/bin/20_routing ${D}${sysconfdir}/utopia/registration.d/20_routing |
| 138 | ln -sf /usr/bin/25_crond ${D}${sysconfdir}/utopia/registration.d/25_crond |
| 139 | ln -sf /usr/bin/26_potd ${D}${sysconfdir}/utopia/registration.d/26_potd |
| 140 | ln -sf /usr/bin/33_cosa ${D}${sysconfdir}/utopia/registration.d/33_cosa |
| 141 | ln -sf /usr/bin/syscfg ${D}${bindir}/syscfg_create |
| 142 | ln -sf /usr/bin/syscfg ${D}${bindir}/syscfg_destroy |
| 143 | ln -sf /usr/bin/firewall ${D}/fss/gw/usr/bin/firewall |
| 144 | ln -sf /usr/bin/GenFWLog ${D}/fss/gw/usr/bin/GenFWLog |
| 145 | ln -sf /etc/utopia/service.d/log_capture_path.sh ${D}/fss/gw/etc/utopia/service.d/log_capture_path.sh |
| 146 | ln -sf /etc/utopia/service.d/log_env_var.sh ${D}/fss/gw/etc/utopia/service.d/log_env_var.sh |
| 147 | ln -sf /usr/bin/syseventd_fork_helper ${D}/fss/gw/usr/bin/syseventd_fork_helper |
| 148 | ln -sf /usr/sbin/log_start.sh ${D}/fss/gw/usr/sbin/log_start.sh |
| 149 | ln -sf /usr/sbin/log_handle.sh ${D}/fss/gw/usr/sbin/log_handle.sh |
| 150 | ln -sf /etc/syslog.conf.utopia ${D}/fss/gw/etc/syslog.conf.utopia |
| 151 | ln -sf /etc/utopia/service.d/misc_handler.sh ${D}/fss/gw/etc/utopia/service.d/misc_handler.sh |
| 152 | |
| 153 | install -m 755 ${WORKDIR}/system_defaults ${D}${sysconfdir}/utopia/system_defaults |
| 154 | sed -i -e "s/ifconfig wan0/ifconfig erouter0/g" ${D}/etc/utopia/service.d/service_sshd.sh |
| 155 | sed -i -e "s/dropbear -E -s -b \/etc\/sshbanner.txt/dropbear -R -E /g" ${D}/etc/utopia/service.d/service_sshd.sh |
| 156 | sed -i -e "/dropbear -R -E -a -r/s/$/ -B/" ${D}${sysconfdir}/utopia/service.d/service_sshd.sh |
| 157 | |
| 158 | #MSG_QUEUE files are not present in turris |
| 159 | sed -i '/TOT_MSG_MAX=\$/ s/^/#/g' ${D}${sysconfdir}/utopia/utopia_init.sh |
| 160 | |
| 161 | echo "###TurrisOmnia specific lines###" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 162 | echo "#TODO: Need to replaced once the sky version 2 code is available" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 163 | echo "sysevent set lan-start 0" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 164 | echo "sysevent set bridge-stop 0" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 165 | echo "sysevent set bridge_mode 0" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 166 | echo "sysevent set dhcp_server-resync 0" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 167 | echo "sysevent set ethwan-initialized 1" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 168 | echo "syscfg set eth_wan_enabled true" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 169 | echo "syscfg commit" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 170 | echo "echo 1 > \/proc\/sys\/net\/ipv4\/ip_forward" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 171 | |
| 172 | echo "sysevent set bridge_mode \`syscfg get bridge_mode\`" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 173 | echo "sysevent set lan-status started" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 174 | echo 'echo_t "[utopia][init] completed creating utopia_inited flag"' >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 175 | |
| 176 | #WanManager Feature |
| 177 | DISTRO_WAN_ENABLED="${@bb.utils.contains('DISTRO_FEATURES','rdkb_wan_manager','true','false',d)}" |
| 178 | if [ $DISTRO_WAN_ENABLED = 'true' ]; then |
| 179 | sed -i '/cron/a \ |
| 180 | \# Creating the dibbler directory for its pid files in \/tmp \ |
| 181 | mkdir -p \/tmp\/dibbler ' ${D}${sysconfdir}/utopia/utopia_init.sh |
| 182 | |
| 183 | sed -i '/log_capture_path.sh/a \ |
| 184 | mkdir -p \/nvram \ |
| 185 | rm -f \/nvram\/dnsmasq.leases \ |
| 186 | cp \/usr\/ccsp\/ccsp_msg.cfg \/tmp \ |
| 187 | touch \/tmp\/cp_subsys_ert \ |
| 188 | ln -s \/var\/spool\/cron\/crontabs \/ \ |
| 189 | mkdir -p \/var\/run\/firewall \ |
| 190 | touch \/nvram\/ETHWAN_ENABLE ' ${D}${sysconfdir}/utopia/utopia_init.sh |
| 191 | |
developer | de36400 | 2022-04-21 20:09:41 +0800 | [diff] [blame] | 192 | echo "firewall" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 193 | echo "execute_dir /etc/utopia/post.d/" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 194 | echo "touch /tmp/.postd_started" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
developer | 15a4331 | 2022-04-12 11:23:23 +0800 | [diff] [blame] | 195 | sed -i '/lan-status started/a \ |
| 196 | sysevent set wan-status started ' ${D}${sysconfdir}/utopia/utopia_init.sh |
| 197 | fi |
| 198 | |
| 199 | echo "touch -f /tmp/utopia_inited" >> ${D}${sysconfdir}/utopia/utopia_init.sh |
| 200 | |
| 201 | } |
| 202 | |
| 203 | do_install_append_dunfell() { |
| 204 | #Following line is for adding Backhaul interface entries in dnsmasq.conf |
| 205 | sed -i '/XB6/i \ \ \ \ \ \ \ elif [ "$BOX_TYPE" = "turris" ]; then\n\ \ \ \ \ \ \ \ \ \ \ echo "interface=wifi2" >> $LOCAL_DHCP_CONF\n\ \ \ \ \ \ \ \ \ \ \ echo "dhcp-range=169.254.0.2,169.254.0.254,255.255.255.0,infinite" >> $LOCAL_DHCP_CONF\n\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if [ "1" == "$NAMESERVERENABLED" ] && [ "$WAN_DHCP_NS" != "" ]; then\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ echo "${PREFIX}""dhcp-option=wifi2,6,$WAN_DHCP_NS" >> $LOCAL_DHCP_CONF\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fi\n\n\ \ \ \ \ \ \ \ \ \ \ echo "interface=wifi3" >> $LOCAL_DHCP_CONF\n\ \ \ \ \ \ \ \ \ \ \ echo "dhcp-range=169.254.1.2,169.254.1.254,255.255.255.0,infinite" >> $LOCAL_DHCP_CONF\n\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if [ "1" == "$NAMESERVERENABLED" ] && [ "$WAN_DHCP_NS" != "" ]; then\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ echo "${PREFIX}""dhcp-option=wifi3,6,$WAN_DHCP_NS" >> $LOCAL_DHCP_CONF\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fi\n\n\ \ \ \ \ \ \ \ \ \ \ echo "interface=br-home" >> $LOCAL_DHCP_CONF\n\ \ \ \ \ \ \ \ \ \ \ echo "dhcp-range=192.168.1.2,192.168.1.253,255.255.255.0,7d" >> $LOCAL_DHCP_CONF\n\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ if [ "1" == "$NAMESERVERENABLED" ] && [ "$WAN_DHCP_NS" != "" ]; then\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ echo "${PREFIX}""dhcp-option=br-home,6,$WAN_DHCP_NS" >> $LOCAL_DHCP_CONF\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ fi\n' ${D}${sysconfdir}/utopia/service.d/service_dhcp_server/dhcp_server_functions.sh |
| 206 | } |
| 207 | |
| 208 | FILES_${PN} += " \ |
| 209 | /rdklogs/ \ |
| 210 | /fss/gw/bin/ \ |
| 211 | /fss/gw/usr/bin/ \ |
| 212 | /fss/gw/usr/sbin/ \ |
| 213 | /var/spool/cron/crontabs \ |
| 214 | /fss/gw/etc/utopia/* \ |
| 215 | /etc/utopia/system_defaults \ |
| 216 | " |
| 217 | |
| 218 | # 0001-fix-lan-handler-for-turris.patch contains bash specific syntax which doesn't run with busybox sh |
| 219 | RDEPENDS_${PN} += "bash" |
| 220 | |