diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 73d3c8d3..95ea741d 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -2086,4 +2086,25 @@ function decryptMenu() { fi ARC_KEY="$(readConfigKey "arc.key" "${USER_CONFIG_FILE}")" return +} + +############################################################################### +# ArcNIC Menu +function arcNIC () { + rm -f "${TMP_PATH}/opts" >/dev/null + touch "${TMP_PATH}/opts" + ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list + # Get actual IP + for ETH in ${ETHX}; do + echo "${ETH}" >>"${TMP_PATH}/opts" + done + dialog --backtitle "$(backtitle)" --title "Arc NIC" \ + --default-item "${ARCNIC}" --menu "Choose a NIC" 0 0 0 --file "${TMP_PATH}/opts" \ + 2>${TMP_PATH}/resp + [ $? -ne 0 ] && return + resp=$(cat ${TMP_PATH}/resp) + [ -z "${resp}" ] && return + ARCNIC=${resp} + writeConfigKey "arc.nic" "${ARCNIC}" "${USER_CONFIG_FILE}" + return } \ No newline at end of file diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index 74cdac03..eea2a63a 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -62,6 +62,7 @@ fi # Get Arc Data from Config ARCIPV6="$(readConfigKey "arc.ipv6" "${USER_CONFIG_FILE}")" +ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" BOOTIPWAIT="$(readConfigKey "arc.bootipwait" "${USER_CONFIG_FILE}")" DIRECTBOOT="$(readConfigKey "arc.directboot" "${USER_CONFIG_FILE}")" @@ -88,7 +89,7 @@ BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" if [ "${OFFLINE}" = "false" ]; then # Update Check - NEWTAG="$(curl -m 5 -skL https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + NEWTAG="$(curl --interface ${ARCNIC} -m 5 -skL https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [ -z "${NEWTAG}" ]; then NEWTAG="${ARC_VERSION}" fi @@ -613,8 +614,8 @@ function make() { --infobox "Get PAT Data from Github..." 3 40 idx=0 while [ ${idx} -le 3 ]; do # Loop 3 times, if successful, break - PAT_URL="$(curl -m 5 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_url")" - PAT_HASH="$(curl -m 5 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_hash")" + PAT_URL="$(curl --interface ${ARCNIC} -m 5 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_url")" + PAT_HASH="$(curl --interface ${ARCNIC} -m 5 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_hash")" PAT_URL=${PAT_URL%%\?*} if [ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ]; then if echo "${PAT_URL}" | grep -q "https://*"; then @@ -630,8 +631,8 @@ function make() { --infobox "Get Github PAT Data failed,\ntry to get from Syno..." 4 40 idx=0 while [ ${idx} -le 5 ]; do # Loop 3 times, if successful, break - PAT_URL="$(curl -m 10 -skL "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}" | jq -r '.info.system.detail[0].items[0].files[0].url')" - PAT_HASH="$(curl -m 10 -skL "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}" | jq -r '.info.system.detail[0].items[0].files[0].checksum')" + PAT_URL="$(curl --interface ${ARCNIC} -m 10 -skL "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}" | jq -r '.info.system.detail[0].items[0].files[0].url')" + PAT_HASH="$(curl --interface ${ARCNIC} -m 10 -skL "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}" | jq -r '.info.system.detail[0].items[0].files[0].checksum')" PAT_URL=${PAT_URL%%\?*} if [ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ]; then if echo "${PAT_URL}" | grep -q "https://*"; then @@ -667,12 +668,10 @@ function make() { fi if [ "${VALID}" = "true" ]; then if [ "${PAT_HASH}" != "${PAT_HASH_CONF}" ] || [ ! -f "${ORI_ZIMAGE_FILE}" ] || [ ! -f "${ORI_RDGZ_FILE}" ]; then - writeConfigKey "arc.paturl" "${PAT_URL}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.pathash" "${PAT_HASH}" "${USER_CONFIG_FILE}" DSM_FILE="${UNTAR_PAT_PATH}/${PAT_HASH}.tar" # Get new Files DSM_URL="https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/files/${MODEL/+/%2B}/${PRODUCTVER}/${PAT_HASH}.tar" - if curl -w "%{http_code}" -skL "${DSM_URL}" -o "${DSM_FILE}"; then + if curl --interface ${ARCNIC} -skL "${DSM_URL}" -o "${DSM_FILE}"; then VALID=true else dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \ @@ -680,7 +679,7 @@ function make() { sleep 5 # Grep PAT_URL PAT_FILE="${TMP_PATH}/${PAT_HASH}.pat" - if curl -w "%{http_code}" -skL "${PAT_URL}" -o "${PAT_FILE}"; then + if curl --interface ${ARCNIC} -skL "${PAT_URL}" -o "${PAT_FILE}"; then VALID=true else dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \ @@ -890,6 +889,7 @@ else echo "p \"Arc Patch Settings \" " >>"${TMP_PATH}/menu" echo "D \"Loader DHCP/StaticIP \" " >>"${TMP_PATH}/menu" echo "R \"Automated Mode: \Z4${CUSTOM}\Zn \" " >>"${TMP_PATH}/menu" + echo "M \"Primary NIC: \Z4${ARCNIC}\Zn \" " >>"${TMP_PATH}/menu" fi if [ "${ADVOPTS}" = "true" ]; then echo "5 \"\Z1Hide Advanced Options\Zn \" " >>"${TMP_PATH}/menu" @@ -1003,6 +1003,7 @@ else fi NEXT="R" ;; + M) arcNIC; NEXT="M" ;; # Advanced Section 5) [ "${ADVOPTS}" = "true" ] && ADVOPTS='false' || ADVOPTS='true' ADVOPTS="${ADVOPTS}" diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index 8dd7ef64..864583fa 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -7,11 +7,12 @@ function updateLoader() { ( local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" + local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break - TAG="$(curl -m 5 -skL https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --interface ${ARCNIC} -m 5 -skL https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [ -n "${TAG}" ]; then echo "New Version: ${TAG}" break @@ -29,8 +30,8 @@ function updateLoader() { fi # Download update file echo "Downloading ${TAG}" - curl -skL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/update.zip" -o "${TMP_PATH}/update.zip" - curl -skL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/update.zip" -o "${TMP_PATH}/update.zip" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" if [ "$(sha256sum "${TMP_PATH}/update.zip" | awk '{print $1}')" = "$(cat ${TMP_PATH}/checksum.sha256 | awk '{print $1}')" ]; then echo "Download successful!" unzip -oq "${TMP_PATH}/update.zip" -d "${TMP_PATH}" @@ -58,11 +59,12 @@ function updateLoader() { function updateAddons() { ( local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" + local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break - TAG="$(curl -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --interface ${ARCNIC} -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [ -n "${TAG}" ]; then echo "New Version: ${TAG}" break @@ -80,8 +82,8 @@ function updateAddons() { fi # Download update file echo "Downloading ${TAG}" - curl -skL "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons.zip" -o "${TMP_PATH}/addons.zip" - curl -skL "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons.zip" -o "${TMP_PATH}/addons.zip" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" if [ "$(sha256sum "${TMP_PATH}/addons.zip" | awk '{print $1}')" = "$(cat ${TMP_PATH}/checksum.sha256 | awk '{print $1}')" ]; then echo "Download successful!" rm -rf "${ADDONS_PATH}" @@ -106,11 +108,12 @@ function updateAddons() { function updatePatches() { ( local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" + local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break - TAG="$(curl -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --interface ${ARCNIC} -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [ -n "${TAG}" ]; then echo "New Version: ${TAG}" break @@ -128,8 +131,8 @@ function updatePatches() { fi # Download update file echo "Downloading ${TAG}" - curl -skL "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip" - curl -skL "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" if [ "$(sha256sum "${TMP_PATH}/patches.zip" | awk '{print $1}')" = "$(cat ${TMP_PATH}/checksum.sha256 | awk '{print $1}')" ]; then echo "Download successful!" rm -rf "${PATCH_PATH}" @@ -154,11 +157,12 @@ function updatePatches() { function updateModules() { ( local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" + local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break - TAG="$(curl -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --interface ${ARCNIC} -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [ -n "${TAG}" ]; then echo "New Version: ${TAG}" break @@ -176,8 +180,8 @@ function updateModules() { fi # Download update file echo "Downloading ${TAG}" - curl -skL "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${TMP_PATH}/modules.zip" - curl -skL "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${TMP_PATH}/modules.zip" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" if [ "$(sha256sum "${TMP_PATH}/modules.zip" | awk '{print $1}')" = "$(cat ${TMP_PATH}/checksum.sha256 | awk '{print $1}')" ]; then echo "Download successful!" rm -rf "${MODULES_PATH}" @@ -221,11 +225,12 @@ function updateModules() { function updateConfigs() { ( local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" + local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break - TAG="$(curl -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --interface ${ARCNIC} -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [ -n "${TAG}" ]; then echo "New Version: ${TAG}" break @@ -243,8 +248,8 @@ function updateConfigs() { fi # Download update file echo "Downloading ${TAG}" - curl -skL "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip" - curl -skL "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/checksum.sha256" -o "${TMP_PATH}/checksum.sha256" if [ "$(sha256sum "${TMP_PATH}/configs.zip" | awk '{print $1}')" = "$(cat ${TMP_PATH}/checksum.sha256 | awk '{print $1}')" ]; then echo "Download successful!" rm -rf "${MODEL_CONFIG_PATH}" @@ -269,11 +274,12 @@ function updateConfigs() { function updateLKMs() { ( local CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" + local ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" if [ -z "${1}" ]; then # Check for new Version idx=0 while [ ${idx} -le 5 ]; do # Loop 5 times, if successful, break - TAG="$(curl -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --interface ${ARCNIC} -m 5 -skL https://api.github.com/repos/AuxXxilium/arc-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [ -n "${TAG}" ]; then echo "New Version: ${TAG}" break @@ -291,7 +297,7 @@ function updateLKMs() { fi # Download update file echo "Downloading ${TAG}" - curl -skL "https://github.com/AuxXxilium/arc-lkm/releases/download/${TAG}/rp-lkms.zip" -o "${TMP_PATH}/rp-lkms.zip" + curl --interface ${ARCNIC} -skL "https://github.com/AuxXxilium/arc-lkm/releases/download/${TAG}/rp-lkms.zip" -o "${TMP_PATH}/rp-lkms.zip" if [ -f "${TMP_PATH}/rp-lkms.zip" ]; then echo "Download successful!" rm -rf "${LKM_PATH}" diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index 1ef651fb..a6d005d0 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -51,12 +51,7 @@ initConfigKey "arc.key" "" "${USER_CONFIG_FILE}" initConfigKey "arc.macsys" "hardware" "${USER_CONFIG_FILE}" initConfigKey "arc.odp" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}" -ARCCONF="$(readConfigKey "${MODEL}.serial" "${S_FILE}" 2>/dev/null)" -if [ -n "${ARCCONF}" ]; then - writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}" -else - writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" -fi +initConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.pathash" "" "${USER_CONFIG_FILE}" initConfigKey "arc.paturl" "" "${USER_CONFIG_FILE}" initConfigKey "arc.sn" "" "${USER_CONFIG_FILE}" @@ -111,6 +106,7 @@ ETHN=$(ls /sys/class/net/ 2>/dev/null | grep eth | wc -l) [ ${NIC} -ne ${ETHN} ] && echo -e "\033[1;31mWarning: NIC mismatch (NICs: ${NIC} | Real: ${ETHN})\033[0m" # Write NIC Amount to config writeConfigKey "device.nic" "${NIC}" "${USER_CONFIG_FILE}" +deleteConfigKey "arc.nic" "${USER_CONFIG_FILE}" # No network devices echo [ ${NIC} -le 0 ] && die "No NIC found! - Loader does not work without Network connection." @@ -158,7 +154,7 @@ elif grep -q "update_arc" /proc/cmdline; then echo -e "\033[1;34mStarting Update Mode...\033[0m" elif [ "${BUILDDONE}" = "true" ]; then echo -e "\033[1;34mStarting DSM Mode...\033[0m" - boot.sh && exit 0 + boot.sh else echo -e "\033[1;34mStarting Config Mode...\033[0m" fi @@ -197,6 +193,8 @@ for ETH in ${ETHX}; do echo -e "\r\033[1;37m${DRIVER} (${SPEED} | ${MSG}):\033[0m LINK LOCAL (No DHCP server detected.)" else echo -e "\r\033[1;37m${DRIVER} (${SPEED} | ${MSG}):\033[0m Access \033[1;34mhttp://${IP}:7681\033[0m to connect to Arc via web." + ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")" + [ -n "${ARCNIC}" ] && writeConfigKey "arc.nic" "${ETH}" "${USER_CONFIG_FILE}" fi ethtool -s ${ETH} wol g 2>/dev/null break