diff --git a/files/initrd/opt/rr/include/functions.sh b/files/initrd/opt/rr/include/functions.sh index 583f3afd..3b09d20e 100755 --- a/files/initrd/opt/rr/include/functions.sh +++ b/files/initrd/opt/rr/include/functions.sh @@ -183,33 +183,35 @@ function validateSerial() { ############################################################################### # Get values in .conf K=V file -# 1 - key -# 2 - file +# 1 - file +# 2 - key function _get_conf_kv() { - grep "^${1}=" "${2}" 2>/dev/null | cut -d'=' -f2- | sed 's/^"//;s/"$//' 2>/dev/null + grep "^${2}=" "${1}" 2>/dev/null | cut -d'=' -f2- | sed 's/^"//;s/"$//' 2>/dev/null + return $? } ############################################################################### # Replace/remove/add values in .conf K=V file -# 1 - name -# 2 - new_val -# 3 - path +# 1 - file +# 2 - key +# 3 - value function _set_conf_kv() { # Delete - if [ -z "${2}" ]; then - sed -i "/^${1}=/d" "${3}" 2>/dev/null + if [ -z "${3}" ]; then + sed -i "/^${2}=/d" "${1}" 2>/dev/null return $? fi # Replace - if grep -q "^${1}=" "${3}"; then - sed -i "s#^${1}=.*#${1}=\"${2}\"#" "${3}" 2>/dev/null + if grep -q "^${2}=" "${1}" 2>/dev/null; then + sed -i "s#^${2}=.*#${2}=\"${3}\"#" "${1}" 2>/dev/null return $? fi # Add if doesn't exist - echo "${1}=\"${2}\"" >>"${3}" - return 0 + mkdir -p "$(dirname "${1}" 2>/dev/null)" 2>/dev/null + echo "${2}=\"${3}\"" >>"${1}" 2>/dev/null + return $? } ############################################################################### diff --git a/files/initrd/opt/rr/menu.sh b/files/initrd/opt/rr/menu.sh index 3c6fce21..3b35e28f 100755 --- a/files/initrd/opt/rr/menu.sh +++ b/files/initrd/opt/rr/menu.sh @@ -428,12 +428,12 @@ function setConfigFromDSM() { return 1 fi - PLATFORMTMP="$(_get_conf_kv "PLATFORM" "${DSM_ROOT}/GRUB_VER")" - MODELTMP="$(_get_conf_kv "MODEL" "${DSM_ROOT}/GRUB_VER")" - majorversion="$(_get_conf_kv "majorversion" "${DSM_ROOT}/VERSION")" - minorversion="$(_get_conf_kv "minorversion" "${DSM_ROOT}/VERSION")" - buildnumber="$(_get_conf_kv "buildnumber" "${DSM_ROOT}/VERSION")" - smallfixnumber="$(_get_conf_kv "smallfixnumber" "${DSM_ROOT}/VERSION")" + PLATFORMTMP="$(_get_conf_kv "${DSM_ROOT}/GRUB_VER" "PLATFORM")" + MODELTMP="$(_get_conf_kv "${DSM_ROOT}/GRUB_VER" "MODEL")" + majorversion="$(_get_conf_kv "${DSM_ROOT}/VERSION" "majorversion")" + minorversion="$(_get_conf_kv "${DSM_ROOT}/VERSION" "minorversion")" + buildnumber="$(_get_conf_kv "${DSM_ROOT}/VERSION" "buildnumber")" + smallfixnumber="$(_get_conf_kv "${DSM_ROOT}/VERSION" "smallfixnumber")" if [ -z "${PLATFORMTMP}" ] || [ -z "${MODELTMP}" ] || [ -z "${majorversion}" ] || [ -z "${minorversion}" ]; then echo -e "$(TEXT "DSM Invalid, try again!")" >"${LOG_FILE}" return 1 @@ -2315,7 +2315,7 @@ function tryRecoveryDSM() { fi if [ -f "${TMP_PATH}/mdX/etc.defaults/synoinfo.conf" ]; then - R_SN="$(_get_conf_kv SN "${TMP_PATH}/mdX/etc.defaults/synoinfo.conf")" + R_SN="$(_get_conf_kv "${TMP_PATH}/mdX/etc.defaults/synoinfo.conf" "SN")" [ -n "${R_SN}" ] && SN=${R_SN} && writeConfigKey "sn" "${SN}" "${USER_CONFIG_FILE}" fi diff --git a/files/initrd/opt/rr/patch/config-manipulators.sh b/files/initrd/opt/rr/patch/config-manipulators.sh deleted file mode 100755 index 4b43471e..00000000 --- a/files/initrd/opt/rr/patch/config-manipulators.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env sh - -# -# WARNING: this file is also embedded in the post-init patcher, so don't go to crazy with the syntax/tools as it must -# be able to execute in the initramfs/preboot environment (so no bashism etc) -# All comments will be stripped, functions here should NOT start with brp_ as they're not part of the builder - -if [ -z "${SED_PATH+x}" ]; then - echo "Your SED_PATH variable is not set/is empty!" - exit 1 -fi - -##$1 from, $2 to, $3 file to path -_replace_in_file() { - if grep -q "${1}" "${3}"; then - "${SED_PATH}" -i "s#${1}#${2}#" "${3}" 2>/dev/null - fi -} - -# Replace/remove/add values in .conf K=V file -# -# Args: $1 name, $2 new_val, $3 path -_set_conf_kv() { - # Delete - if [ -z "${2}" ]; then - "${SED_PATH}" -i "/^${1}=/d" "${3}" 2>/dev/null - return 0 - fi - - # Replace - if grep -q "^${1}=" "${3}"; then - "${SED_PATH}" -i "s#^${1}=.*#${1}=\"${2}\"#" "${3}" 2>/dev/null - return 0 - fi - - # Add if doesn't exist - echo "${1}=\"${2}\"" >>"${3}" - return 0 -} diff --git a/files/initrd/opt/rr/patch/ramdisk-disable-disabled-ports-00000.patch b/files/initrd/opt/rr/patch/ramdisk-disable-disabled-ports-00000.patch deleted file mode 100644 index 3ea5eb70..00000000 --- a/files/initrd/opt/rr/patch/ramdisk-disable-disabled-ports-00000.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/usr/syno/web/webman/get_state.cgi -+++ b/usr/syno/web/webman/get_state.cgi -@@ -1,7 +1,7 @@ - #!/bin/sh - - PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin" --DisabledPortDisks=`/usr/syno/bin/synodiskport -portthawlist` -+DisabledPortDisks="" - partition=`/usr/syno/bin/synodiskport -installable_disk_list` - - product=`/bin/get_key_value /etc.defaults/synoinfo.conf product` diff --git a/files/initrd/opt/rr/patch/ramdisk-disable-disabled-ports-42661.patch b/files/initrd/opt/rr/patch/ramdisk-disable-disabled-ports-42661.patch deleted file mode 100644 index 5f7b2234..00000000 --- a/files/initrd/opt/rr/patch/ramdisk-disable-disabled-ports-42661.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/usr/syno/web/webman/get_state.cgi -+++ b/usr/syno/web/webman/get_state.cgi -@@ -1,7 +1,7 @@ - #!/bin/sh - - PATH="$PATH:/bin:/sbin:/usr/bin:/usr/sbin" --DisabledPortDisks="$(/usr/syno/bin/synodiskport -portthawlist)" -+DisabledPortDisks="" - partition="$(/usr/syno/bin/synodiskport -installable_disk_list)" - - upnpmodelname="$(/bin/get_key_value /etc.defaults/synoinfo.conf upnpmodelname)" diff --git a/files/initrd/opt/rr/patch/ramdisk-disable-root-pwd-00000.patch b/files/initrd/opt/rr/patch/ramdisk-disable-root-pwd-00000.patch deleted file mode 100644 index d4d5b6d0..00000000 --- a/files/initrd/opt/rr/patch/ramdisk-disable-root-pwd-00000.patch +++ /dev/null @@ -1,8 +0,0 @@ ---- a/etc/passwd -+++ b/etc/passwd -@@ -1,4 +1,4 @@ --root:x:0:0::/root:/bin/ash -+root::0:0::/root:/bin/ash - system:x:1:1::/usr/syno/synoman:/usr/bin/nologin - daemon:x:2:2::/:/bin/sh - lp:x:7:7::/var/spool/lpd:/bin/sh diff --git a/files/initrd/opt/rr/patch/ramdisk-disable-root-pwd-64216.patch b/files/initrd/opt/rr/patch/ramdisk-disable-root-pwd-64216.patch deleted file mode 100644 index 84e54608..00000000 --- a/files/initrd/opt/rr/patch/ramdisk-disable-root-pwd-64216.patch +++ /dev/null @@ -1,8 +0,0 @@ ---- a/etc/passwd -+++ b/etc/passwd -@@ -1,4 +1,4 @@ --root:x:0:0::/root:/bin/ash -+root::0:0::/root:/bin/ash - system:x:1:1::/usr/syno/synoman:/usr/bin/nologin - daemon:x:2:2::/:/bin/sh - SYSTEM_ADMIN:x:3:101::/nonexist:/usr/bin/nologin diff --git a/files/initrd/opt/rr/patch/ramdisk-etc-rc-00000.patch b/files/initrd/opt/rr/patch/ramdisk-etc-rc-25556.patch similarity index 100% rename from files/initrd/opt/rr/patch/ramdisk-etc-rc-00000.patch rename to files/initrd/opt/rr/patch/ramdisk-etc-rc-25556.patch diff --git a/files/initrd/opt/rr/patch/ramdisk-init-script-00000.patch b/files/initrd/opt/rr/patch/ramdisk-init-script-42218.patch similarity index 100% rename from files/initrd/opt/rr/patch/ramdisk-init-script-00000.patch rename to files/initrd/opt/rr/patch/ramdisk-init-script-42218.patch diff --git a/files/initrd/opt/rr/patch/ramdisk-network-hosts-00000.patch b/files/initrd/opt/rr/patch/ramdisk-network-hosts-00000.patch deleted file mode 100644 index b6c953b6..00000000 --- a/files/initrd/opt/rr/patch/ramdisk-network-hosts-00000.patch +++ /dev/null @@ -1,8 +0,0 @@ ---- /etc/hosts -+++ /etc/hosts -@@ -2,3 +2,5 @@ - # that require network functionality will fail. - 127.0.0.1 localhost - ::1 localhost -+127.0.0.1 update7.synology.com -+127.0.0.1 dataupdate7.synology.com diff --git a/files/initrd/opt/rr/patch/ramdisk-post-init-script-00000.patch b/files/initrd/opt/rr/patch/ramdisk-post-init-script-00000.patch deleted file mode 100644 index c0052bb7..00000000 --- a/files/initrd/opt/rr/patch/ramdisk-post-init-script-00000.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- a/usr/sbin/init.post -+++ b/usr/sbin/init.post -@@ -18,6 +18,29 @@ if [ "$UniqueRD" = "nextkvmx64" ]; then - fi - Mount "$RootDevice" /tmpRoot -o barrier=1 - -+############################################################################################ -+SED_PATH='/tmpRoot/usr/bin/sed' -+ -+@@@CONFIG-MANIPULATORS-TOOLS@@@ -+ -+@@@CONFIG-GENERATED@@@ -+ -+UPSTART="/tmpRoot/usr/share/init" -+ -+if ! echo; then -+ _replace_in_file '^start on' '#start on' $UPSTART/tty.conf -+ _replace_in_file "console output" "console none" $UPSTART/syno_poweroff_task.conf -+ _replace_in_file "console output" "console none" $UPSTART/burnin_loader.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevtrigger.conf -+ _replace_in_file "console output" "console none" $UPSTART/bs-poweroff.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevd.conf -+else -+ _replace_in_file '^#start on' 'start on' $UPSTART/tty.conf -+fi -+ -+/addons/addons.sh late -+############################################################################################ -+ - Mkdir -p /tmpRoot/initrd - - Umount /proc >/dev/null 2>&1 diff --git a/files/initrd/opt/rr/patch/ramdisk-post-init-script-25556.patch b/files/initrd/opt/rr/patch/ramdisk-post-init-script-25556.patch index 0ca1c9e3..9213c75f 100644 --- a/files/initrd/opt/rr/patch/ramdisk-post-init-script-25556.patch +++ b/files/initrd/opt/rr/patch/ramdisk-post-init-script-25556.patch @@ -1,31 +1,10 @@ --- a/usr/sbin/init.post +++ b/usr/sbin/init.post -@@ -18,6 +18,29 @@ +@@ -18,6 +18,8 @@ fi mount $RootDevice /tmpRoot -o barrier=1 -+############################################################################################ -+SED_PATH='/tmpRoot/usr/bin/sed' -+ -+@@@CONFIG-MANIPULATORS-TOOLS@@@ -+ -+@@@CONFIG-GENERATED@@@ -+ -+UPSTART="/tmpRoot/usr/share/init" -+ -+if ! echo; then -+ _replace_in_file '^start on' '#start on' $UPSTART/tty.conf -+ _replace_in_file "console output" "console none" $UPSTART/syno_poweroff_task.conf -+ _replace_in_file "console output" "console none" $UPSTART/burnin_loader.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevtrigger.conf -+ _replace_in_file "console output" "console none" $UPSTART/bs-poweroff.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevd.conf -+else -+ _replace_in_file '^#start on' 'start on' $UPSTART/tty.conf -+fi -+ +/addons/addons.sh late -+############################################################################################ + mkdir -p /tmpRoot/initrd diff --git a/files/initrd/opt/rr/patch/ramdisk-post-init-script-42218.patch b/files/initrd/opt/rr/patch/ramdisk-post-init-script-42218.patch new file mode 100644 index 00000000..ec529e19 --- /dev/null +++ b/files/initrd/opt/rr/patch/ramdisk-post-init-script-42218.patch @@ -0,0 +1,11 @@ +--- a/usr/sbin/init.post ++++ b/usr/sbin/init.post +@@ -18,6 +18,8 @@ + fi + Mount "$RootDevice" /tmpRoot -o barrier=1 + ++/addons/addons.sh late ++ + Mkdir -p /tmpRoot/initrd + + Umount /proc >/dev/null 2>&1 diff --git a/files/initrd/opt/rr/patch/ramdisk-post-init-script-42661.patch b/files/initrd/opt/rr/patch/ramdisk-post-init-script-42661.patch index 762cd4f2..93275eea 100644 --- a/files/initrd/opt/rr/patch/ramdisk-post-init-script-42661.patch +++ b/files/initrd/opt/rr/patch/ramdisk-post-init-script-42661.patch @@ -1,31 +1,11 @@ --- a/usr/sbin/init.post +++ b/usr/sbin/init.post -@@ -31,7 +31,28 @@ - OptPrjQuota="$(GetPQMountOpt "${RootMountPath}")" +@@ -32,6 +32,8 @@ # shellcheck disable=SC2046 Mount "${RootMountPath}" /tmpRoot -o barrier=1 ${OptPrjQuota} -+############################################################################################ -+SED_PATH='/tmpRoot/usr/bin/sed' -+@@@CONFIG-MANIPULATORS-TOOLS@@@ -+ -+@@@CONFIG-GENERATED@@@ -+ -+UPSTART="/tmpRoot/usr/share/init" -+ -+if ! echo; then -+ _replace_in_file '^start on' '#start on' $UPSTART/tty.conf -+ _replace_in_file "console output" "console none" $UPSTART/syno_poweroff_task.conf -+ _replace_in_file "console output" "console none" $UPSTART/burnin_loader.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevtrigger.conf -+ _replace_in_file "console output" "console none" $UPSTART/bs-poweroff.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevd.conf -+else -+ _replace_in_file '^#start on' 'start on' $UPSTART/tty.conf -+fi -+ +/addons/addons.sh late -+############################################################################################ ++ Mkdir -p /tmpRoot/initrd Umount /proc >/dev/null 2>&1 diff --git a/files/initrd/opt/rr/patch/ramdisk-post-init-script-42951.patch b/files/initrd/opt/rr/patch/ramdisk-post-init-script-42951.patch index e6db176f..9e3af8e7 100644 --- a/files/initrd/opt/rr/patch/ramdisk-post-init-script-42951.patch +++ b/files/initrd/opt/rr/patch/ramdisk-post-init-script-42951.patch @@ -1,31 +1,11 @@ --- a/usr/sbin/init.post +++ b/usr/sbin/init.post -@@ -31,7 +31,28 @@ - OptPrjQuota="$(GetPQMountOpt "${RootMountPath}")" +@@ -32,6 +32,8 @@ # shellcheck disable=SC2046 Mount "${RootMountPath}" /tmpRoot -o barrier=1,noatime ${OptPrjQuota} -+############################################################################################ -+SED_PATH='/tmpRoot/usr/bin/sed' -+@@@CONFIG-MANIPULATORS-TOOLS@@@ -+ -+@@@CONFIG-GENERATED@@@ -+ -+UPSTART="/tmpRoot/usr/share/init" -+ -+if ! echo; then -+ _replace_in_file '^start on' '#start on' $UPSTART/tty.conf -+ _replace_in_file "console output" "console none" $UPSTART/syno_poweroff_task.conf -+ _replace_in_file "console output" "console none" $UPSTART/burnin_loader.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevtrigger.conf -+ _replace_in_file "console output" "console none" $UPSTART/bs-poweroff.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevd.conf -+else -+ _replace_in_file '^#start on' 'start on' $UPSTART/tty.conf -+fi -+ +/addons/addons.sh late -+############################################################################################ ++ Mkdir -p /tmpRoot/initrd Umount /proc >/dev/null 2>&1 diff --git a/files/initrd/opt/rr/patch/ramdisk-post-init-script-69057.patch b/files/initrd/opt/rr/patch/ramdisk-post-init-script-69057.patch index fff25685..f5bf3d71 100644 --- a/files/initrd/opt/rr/patch/ramdisk-post-init-script-69057.patch +++ b/files/initrd/opt/rr/patch/ramdisk-post-init-script-69057.patch @@ -1,31 +1,11 @@ --- a/usr/sbin/init.post +++ b/usr/sbin/init.post -@@ -31,7 +31,28 @@ - fi +@@ -23,6 +23,8 @@ Mount "$(GetRootMountOpt)" "$(GetRootMountPath)" /tmpRoot -+############################################################################################ -+SED_PATH='/tmpRoot/usr/bin/sed' -+@@@CONFIG-MANIPULATORS-TOOLS@@@ -+ -+@@@CONFIG-GENERATED@@@ -+ -+UPSTART="/tmpRoot/usr/share/init" -+ -+if ! echo; then -+ _replace_in_file '^start on' '#start on' $UPSTART/tty.conf -+ _replace_in_file "console output" "console none" $UPSTART/syno_poweroff_task.conf -+ _replace_in_file "console output" "console none" $UPSTART/burnin_loader.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevtrigger.conf -+ _replace_in_file "console output" "console none" $UPSTART/bs-poweroff.conf -+ _replace_in_file "console output" "console none" $UPSTART/udevd.conf -+else -+ _replace_in_file '^#start on' 'start on' $UPSTART/tty.conf -+fi -+ +/addons/addons.sh late -+############################################################################################ ++ Mkdir -p /tmpRoot/initrd Umount /proc >/dev/null 2>&1 diff --git a/files/initrd/opt/rr/ramdisk-patch.sh b/files/initrd/opt/rr/ramdisk-patch.sh index 74f32da8..ea38fbe7 100755 --- a/files/initrd/opt/rr/ramdisk-patch.sh +++ b/files/initrd/opt/rr/ramdisk-patch.sh @@ -81,14 +81,11 @@ writeConfigKey "productver" "${PRODUCTVER}" "${USER_CONFIG_FILE}" writeConfigKey "buildnum" "${BUILDNUM}" "${USER_CONFIG_FILE}" writeConfigKey "smallnum" "${SMALLNUM}" "${USER_CONFIG_FILE}" -declare -A SYNOINFO declare -A ADDONS declare -A MODULES +declare -A SYNOINFO -# Read synoinfo and addons from config -while IFS=': ' read -r KEY VALUE; do - [ -n "${KEY}" ] && SYNOINFO["${KEY}"]="${VALUE}" -done <<<"$(readConfigMap "synoinfo" "${USER_CONFIG_FILE}")" +# Read addons, modules and synoinfo from user config while IFS=': ' read -r KEY VALUE; do [ -n "${KEY}" ] && ADDONS["${KEY}"]="${VALUE}" done <<<"$(readConfigMap "addons" "${USER_CONFIG_FILE}")" @@ -98,13 +95,16 @@ while IFS=': ' read -r KEY VALUE; do [ -n "${KEY}" ] && MODULES["${KEY}"]="${VALUE}" done <<<"$(readConfigMap "modules" "${USER_CONFIG_FILE}")" +SYNOINFO["SN"]="${SN}" +while IFS=': ' read -r KEY VALUE; do + [ -n "${KEY}" ] && SYNOINFO["${KEY}"]="${VALUE}" +done <<<"$(readConfigMap "synoinfo" "${USER_CONFIG_FILE}")" + # Patches (diff -Naru OLDFILE NEWFILE > xxx.patch) PATCHS=( "ramdisk-etc-rc-*.patch" "ramdisk-init-script-*.patch" "ramdisk-post-init-script-*.patch" - "ramdisk-disable-root-pwd-*.patch" - "ramdisk-disable-disabled-ports-*.patch" ) for PE in "${PATCHS[@]}"; do RET=1 @@ -121,50 +121,11 @@ for PE in "${PATCHS[@]}"; do [ ${RET} -ne 0 ] && exit 1 done -# Patch /etc/synoinfo.conf /etc.defaults/synoinfo.conf -echo -n "." -# Add serial number to synoinfo.conf, to help to recovery a installed DSM -echo "Set synoinfo SN" >"${LOG_FILE}" -_set_conf_kv "SN" "${SN}" "${RAMDISK_PATH}/etc/synoinfo.conf" >>"${LOG_FILE}" 2>&1 || exit 1 -_set_conf_kv "SN" "${SN}" "${RAMDISK_PATH}/etc.defaults/synoinfo.conf" >>"${LOG_FILE}" 2>&1 || exit 1 -for KEY in "${!SYNOINFO[@]}"; do - echo "Set synoinfo ${KEY}" >>"${LOG_FILE}" - _set_conf_kv "${KEY}" "${SYNOINFO[${KEY}]}" "${RAMDISK_PATH}/etc/synoinfo.conf" >>"${LOG_FILE}" 2>&1 || exit 1 - _set_conf_kv "${KEY}" "${SYNOINFO[${KEY}]}" "${RAMDISK_PATH}/etc.defaults/synoinfo.conf" >>"${LOG_FILE}" 2>&1 || exit 1 -done - -# Patch /sbin/init.post -# Apply config manipulators -grep -v -e '^[\t ]*#' -e '^$' "${WORK_PATH}/patch/config-manipulators.sh" >"${TMP_PATH}/rp.txt" -sed -e "/@@@CONFIG-MANIPULATORS-TOOLS@@@/ {" -e "r ${TMP_PATH}/rp.txt" -e 'd' -e '}' -i "${RAMDISK_PATH}/sbin/init.post" -rm -f "${TMP_PATH}/rp.txt" - -# Generate synoinfo configurations -{ - echo "_set_conf_kv 'SN' '${SN}' '/tmpRoot/etc/synoinfo.conf'" - echo "_set_conf_kv 'SN' '${SN}' '/tmpRoot/etc.defaults/synoinfo.conf'" - for KEY in "${!SYNOINFO[@]}"; do - echo "_set_conf_kv '${KEY}' '${SYNOINFO[${KEY}]}' '/tmpRoot/etc/synoinfo.conf'" - echo "_set_conf_kv '${KEY}' '${SYNOINFO[${KEY}]}' '/tmpRoot/etc.defaults/synoinfo.conf'" - done -} >"${TMP_PATH}/rp.txt" - -sed -e "/@@@CONFIG-GENERATED@@@/ {" -e "r ${TMP_PATH}/rp.txt" -e 'd' -e '}' -i "${RAMDISK_PATH}/sbin/init.post" -rm -f "${TMP_PATH}/rp.txt" - -# Extract ck modules to ramdisk -echo -n "." -installModules "${PLATFORM}" "${KPRE:+${KPRE}-}${KVER}" "${!MODULES[@]}" || exit 1 - -# Copying fake modprobe -[ "$(echo "${KVER:-4}" | cut -d'.' -f1)" -lt 5 ] && cp -f "${WORK_PATH}/patch/iosched-trampoline.sh" "${RAMDISK_PATH}/usr/sbin/modprobe" -# Copying LKM to /usr/lib/modules -gzip -dc "${LKMS_PATH}/rp-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}-${LKM}.ko.gz" >"${RAMDISK_PATH}/usr/lib/modules/rp.ko" 2>"${LOG_FILE}" || exit 1 +mkdir -p "${RAMDISK_PATH}/addons" # Addons echo -n "." echo "Create addons.sh" >"${LOG_FILE}" -mkdir -p "${RAMDISK_PATH}/addons" { echo "#!/bin/sh" echo 'echo "addons.sh called with params ${@}"' @@ -200,8 +161,32 @@ for ADDON in "${!ADDONS[@]}"; do echo "/addons/${ADDON}.sh \${1} ${PARAMS}" >>"${RAMDISK_PATH}/addons/addons.sh" 2>>"${LOG_FILE}" || exit 1 done -# Enable Telnet -echo "inetd" >>"${RAMDISK_PATH}/addons/addons.sh" +# Extract ck modules to ramdisk +echo -n "." +installModules "${PLATFORM}" "${KPRE:+${KPRE}-}${KVER}" "${!MODULES[@]}" || exit 1 + +# Copying fake modprobe +[ "$(echo "${KVER:-4}" | cut -d'.' -f1)" -lt 5 ] && cp -f "${WORK_PATH}/patch/iosched-trampoline.sh" "${RAMDISK_PATH}/usr/sbin/modprobe" +# Copying LKM to /usr/lib/modules +gzip -dc "${LKMS_PATH}/rp-${PLATFORM}-${KPRE:+${KPRE}-}${KVER}-${LKM}.ko.gz" >"${RAMDISK_PATH}/usr/lib/modules/rp.ko" 2>"${LOG_FILE}" || exit 1 + +# Patch synoinfo.conf +echo -n "." +echo -n "" >"${RAMDISK_PATH}/addons/synoinfo.conf" +for KEY in "${!SYNOINFO[@]}"; do + echo "Set synoinfo ${KEY}" >>"${LOG_FILE}" + echo "${KEY}=\"${SYNOINFO[${KEY}]}\"" >>"${RAMDISK_PATH}/addons/synoinfo.conf" + _set_conf_kv "${RAMDISK_PATH}/etc/synoinfo.conf" "${KEY}" "${SYNOINFO[${KEY}]}" || exit 1 + _set_conf_kv "${RAMDISK_PATH}/etc.defaults/synoinfo.conf" "${KEY}" "${SYNOINFO[${KEY}]}" || exit 1 +done +if [ ! -x "${RAMDISK_PATH}/usr/bin/get_key_value" ]; then + printf '#!/bin/sh\n%s\n_get_conf_kv "$@"' "$(declare -f _get_conf_kv)" >"${RAMDISK_PATH}/usr/bin/get_key_value" + chmod a+x "${RAMDISK_PATH}/usr/bin/get_key_value" +fi +if [ ! -x "${RAMDISK_PATH}/usr/bin/set_key_value" ]; then + printf '#!/bin/sh\n%s\n_set_conf_kv "$@"' "$(declare -f _set_conf_kv)" >"${RAMDISK_PATH}/usr/bin/set_key_value" + chmod a+x "${RAMDISK_PATH}/usr/bin/set_key_value" +fi echo -n "." echo "Modify files" >"${LOG_FILE}"