diff --git a/.github/workflows/custom.yml b/.github/workflows/custom.yml index 59a29be0..49570d92 100644 --- a/.github/workflows/custom.yml +++ b/.github/workflows/custom.yml @@ -31,12 +31,10 @@ jobs: # -*- coding: utf-8 -*- import json, subprocess def set_output(name, value): - subprocess.call("echo '{}={}' >> $GITHUB_ENV".format(name, value), shell=True) + subprocess.call(["echo '{}={}' >> $GITHUB_ENV".format(name, value)], shell=True) issuetitle = ${{ toJSON(github.event.issue.title) }}; issuebody = ${{ toJSON(github.event.issue.body) }}; - - iscustom = 'false' MODEL = '' PRODUCTVER = '' @@ -44,18 +42,14 @@ jobs: MACSYS = '' FORMAT = '' try: - if issuetitle.lower().startswith('custom'): - jsonbody = json.loads(issuebody) - iscustom = 'true' - MODEL = jsonbody.get('model', '') - PRODUCTVER = jsonbody.get('version', '') - ADDONS = jsonbody.get('addons', '') - MACSYS = jsonbody.get('macsys', '') - FORMAT = jsonbody.get('format', '') + jsonbody = json.loads(issuebody) + MODEL = jsonbody.get('model', '') + PRODUCTVER = jsonbody.get('version', '') + ADDONS = jsonbody.get('addons', '') + MACSYS = jsonbody.get('macsys', '') + FORMAT = jsonbody.get('format', '') except ValueError as e: pass - - set_output("iscustom", iscustom) set_output("MODEL", MODEL) set_output("PRODUCTVER", PRODUCTVER) @@ -80,7 +74,6 @@ jobs: fi - name: Update Comment Building - if: env.iscustom == 'true' id: comment uses: actions-cool/issues-helper@v3 with: @@ -95,7 +88,6 @@ jobs: # Get extractor, LKM, Addons, Modules and Configs - name: Get extractor, LKM, Addons, Extensions, Modules and Configs - if: env.iscustom == 'true' run: | sudo apt update sudo apt install -y jq gawk cpio gettext libelf-dev qemu-utils busybox dialog curl sed @@ -114,10 +106,13 @@ jobs: # Build incremental - name: Build image - if: env.iscustom == 'true' run: | . scripts/func.sh + function writeConfigKey() { + [ "${2}" = "{}" ] && sudo yq eval '.'${1}' = {}' --inplace "${3}" 2>/dev/null || sudo yq eval '.'${1}' = "'"${2}"'"' --inplace "${3}" 2>/dev/null + } + echo "Create Arc Image" IMAGE_FILE="arc.img" gzip -dc "files/initrd/opt/arc/grub.img.gz" >"${IMAGE_FILE}" @@ -141,18 +136,22 @@ jobs: repackInitrd "br/initrd-arc" "files/initrd" "files/p3/initrd-arc" echo "Set Custom Config" - echo "model: ${{ env.MODEL }}" >"files/p1/preset-config.yml" - echo "model: ${{ env.MODEL }}" - echo "productver: ${{ env.PRODUCTVER }}" >>"files/p1/preset-config.yml" - echo "productver: ${{ env.PRODUCTVER }}" - echo "arc:" >>"files/p1/preset-config.yml" - echo "macsys: ${{ env.MACSYS }}" >>"files/p1/preset-config.yml" - echo " macsys: ${{ env.MACSYS }}" - echo "addons:" >>"files/p1/preset-config.yml" - for ADDON in ${{ env.ADDONS }}; do - echo " ${ADDON}: \"\"" | sed 's/,//g' | sed 's/\[//g' | sed 's/\]//g' >>"files/p1/preset-config.yml" - done - echo "addons: ${{ env.ADDONS }}" + PRESET_CONFIG_FILE="files/p1/user-config.yml" + touch "${PRESET_CONFIG_FILE}" + writeConfigKey "model" "${{ env.MODEL }}" "${PRESET_CONFIG_FILE}" + writeConfigKey "productver" "${{ env.PRODUCTVER }}" "${PRESET_CONFIG_FILE}" + writeConfigKey "arc" "{}" "${PRESET_CONFIG_FILE}" + writeConfigKey "arc.macsys" "${{ env.MACSYS }}" "${PRESET_CONFIG_FILE}" + writeConfigKey "arc.custom" "true" "${PRESET_CONFIG_FILE}" + writeConfigKey "addons" "{}" "${PRESET_CONFIG_FILE}" + if [ -n "${{ env.ADDONS }}" ]; then + writeConfigKey "addons" "{}" "${PRESET_CONFIG_FILE}" + for A in $(echo "${{ env.ADDONS }}" | tr ',' ' ' | sed 's/\[//g' | sed 's/\]//g'); do + VALUE="" + writeConfigKey "addons.\"${A}\"" "${VALUE}" "${PRESET_CONFIG_FILE}" + done + fi + echo "$(cat "${PRESET_CONFIG_FILE}")" echo "arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}" >"files/p3/automated" echo "Copying files" sudo cp -Rf "files/p1/"* "/tmp/p1" @@ -177,7 +176,6 @@ jobs: # Zip image and generate checksum - name: Pack - if: env.iscustom == 'true' run: | if [ "${{ env.FORMAT }}" = "img" ]; then zip -9 "arc-${{ env.MODEL }}-${{ env.PRODUCTVER }}-${{ env.VERSION }}.img.zip" arc.img @@ -208,7 +206,7 @@ jobs: echo "FIOURL=${FIOURL}" >> $GITHUB_ENV - name: Send mail - if: env.iscustom == 'true' && success() && env.EMAIL != 'null' + if: success() && env.EMAIL != 'null' uses: dawidd6/action-send-mail@v3 with: server_address: smtp.gmail.com @@ -222,7 +220,7 @@ jobs: ${{ env.FIOURL }} - name: Update Comment Success - if: env.iscustom == 'true' && success() + if: success() uses: actions-cool/issues-helper@v3 with: actions: 'update-comment' @@ -236,7 +234,7 @@ jobs: ---- - name: Close Issues - if: env.iscustom == 'true' && success() + if: success() uses: actions-cool/issues-helper@v3 with: actions: 'close-issue' @@ -244,7 +242,7 @@ jobs: issue-number: ${{ github.event.issue.number }} - name: Update Comment Fail - if: env.iscustom == 'true' && failure() + if: failure() uses: actions-cool/issues-helper@v3 with: actions: 'update-comment' diff --git a/.github/workflows/data.yml b/.github/workflows/data.yml index 2e8ef949..9bddb544 100644 --- a/.github/workflows/data.yml +++ b/.github/workflows/data.yml @@ -32,18 +32,18 @@ jobs: . scripts/func.sh models="{" WORK_PATH="files/p3" - mkdir -p "${WORK_PATH}/autoconfigs" - getConfigs "${WORK_PATH}/autoconfigs" - for M in $(find "${WORK_PATH}/autoconfigs" -maxdepth 1 -name \*.yml 2>/dev/null | sed 's/.*\///; s/\.yml//'); do + mkdir -p "${WORK_PATH}/configs" + getConfigs "${WORK_PATH}/configs" + for M in $(find "${WORK_PATH}/configs" -maxdepth 1 -name \*.yml 2>/dev/null | sed 's/.*\///; s/\.yml//'); do models+="\"${M}\":[" - for V in $(yq eval '.productvers | explode(.) | to_entries | map([.key])[] | .[]' "${WORK_PATH}/autoconfigs/${M}.yml" 2>/dev/null | sort -r); do + for V in $(yq eval '.productvers | explode(.) | to_entries | map([.key])[] | .[]' "${WORK_PATH}/configs/${M}.yml" 2>/dev/null | sort -r); do models+="\"${V}\"," done models="${models%,}]," done models="${models%,}}" echo "${models}" >docs/models.json - rm -rf "${WORK_PATH}/autoconfigs" + rm -rf "${WORK_PATH}/configs" - name: Check and Push if: success() && inputs.push == true diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index f541e57c..a75415f6 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -21,6 +21,7 @@ function editUserConfig() { fi writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + return } ############################################################################### @@ -29,6 +30,7 @@ function addonMenu() { addonSelection writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + return } function addonSelection() { @@ -206,6 +208,7 @@ function modulesMenu() { ;; esac done + return } ############################################################################### @@ -407,6 +410,7 @@ function cmdlineMenu() { ;; esac done + return } ############################################################################### @@ -495,11 +499,11 @@ function synoinfoMenu() { DT="$(readModelKey "${MODEL}" "dt")" if [[ "${CONFDONE}" = "true" && "${DT}" = "true" ]]; then if findAndMountDSMRoot; then - if [ -f "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml" ]; then - if [ -f "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml.bak" ]; then - cp -f "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml.bak" "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml" + if [ -f "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml" ]; then + if [ -f "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml.bak" ]; then + cp -f "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml.bak" "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml" fi - cp -f "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml" "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml.bak" + cp -f "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml" "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml.bak" dialog --backtitle "$(backtitle)" --title "Thermal Shutdown" \ --inputbox "CPU Temperature: (Default 90 °C)" 0 0 \ 2>"${TMP_PATH}/resp" @@ -507,9 +511,9 @@ function synoinfoMenu() { [ ${RET} -ne 0 ] && break 2 CPUTEMP=$(cat "${TMP_PATH}/resp") if [ "${PLATFORM}" = "geminilake" ]; then - sed -i 's|90|'"${CPUTEMP}"'|g' "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml" + sed -i 's|90|'"${CPUTEMP}"'|g' "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml" elif [[ "${PLATFORM}" = "r1000" || "${PLATFORM}" = "v1000" || "${PLATFORM}" = "epyc7002" ]]; then - sed -i 's|||g' "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml" + sed -i 's|||g' "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml" fi dialog --backtitle "$(backtitle)" --title "Thermal Shutdown" \ --inputbox "Disk Temperature: (Default 61 °C)" 0 0 \ @@ -518,9 +522,9 @@ function synoinfoMenu() { [ ${RET} -ne 0 ] && break 2 DISKTEMP=$(cat "${TMP_PATH}/resp") if [ "${PLATFORM}" = "geminilake" ]; then - sed -i 's|61|'"${DISKTEMP}"'|g' "/mnt/dsmroot/usr/syno/etc.defaults/scemd.xml" + sed -i 's|61|'"${DISKTEMP}"'|g' "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml" elif [[ "${PLATFORM}" = "r1000" || "${PLATFORM}" = "v1000" || "${PLATFORM}" = "epyc7002" ]]; then - sed -i 's|||g' "/mnt/dsmroot/usr/syno/etc.defaults/scemd.xml" + sed -i 's|||g' "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml" fi dialog --backtitle "$(backtitle)" --title "Thermal Shutdown" \ --inputbox "M.2 Temperature: (Default 70 °C)" 0 0 \ @@ -529,9 +533,9 @@ function synoinfoMenu() { [ ${RET} -ne 0 ] && break 2 M2TEMP=$(cat "${TMP_PATH}/resp") if [ "${PLATFORM}" = "geminilake" ]; then - sed -i 's|70|'"${M2TEMP}"'|g' "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml" + sed -i 's|70|'"${M2TEMP}"'|g' "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml" elif [[ "${PLATFORM}" = "r1000" || "${PLATFORM}" = "v1000" || "${PLATFORM}" = "epyc7002" ]]; then - sed -i 's|||g' "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml" + sed -i 's|||g' "${TMP_PATH}/mdX/usr/syno/etc.defaults/scemd.xml" fi dialog --backtitle "$(backtitle)" --title "Thermal Shutdown" --aspect 18 \ --msgbox "Change Thermal Shutdown Settings successful!\nCPU: ${CPUTEMP}\nDisk: ${DISKTEMP}\nM.2: ${M2TEMP}" 0 0 @@ -550,6 +554,7 @@ function synoinfoMenu() { ;; esac done + return } ############################################################################### @@ -575,6 +580,7 @@ function keymapMenu() { writeConfigKey "layout" "${LAYOUT}" "${USER_CONFIG_FILE}" writeConfigKey "keymap" "${KEYMAP}" "${USER_CONFIG_FILE}" loadkeys /usr/share/keymaps/i386/${LAYOUT}/${KEYMAP}.map.gz + return } ############################################################################### @@ -603,6 +609,7 @@ function storagepanelMenu() { writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" fi + return } ############################################################################### @@ -677,53 +684,26 @@ function backupMenu() { if findAndMountDSMRoot; then MODEL="" PRODUCTVER="" - if [ -f "${DSMROOT_PATH}/.syno/patch/VERSION" ]; then - eval $(cat ${DSMROOT_PATH}/.syno/patch/VERSION | grep unique) - eval $(cat ${DSMROOT_PATH}/.syno/patch/VERSION | grep majorversion) - eval $(cat ${DSMROOT_PATH}/.syno/patch/VERSION | grep minorversion) - if [ -n "${unique}" ] ; then - while read -r F; do - M="$(basename ${F})" - M="${M::-4}" - UNIQUE="$(readModelKey "${M}" "unique")" - [ "${unique}" = "${UNIQUE}" ] || continue - # Found - writeConfigKey "model" "${M}" "${USER_CONFIG_FILE}" - done <<<$(find "${MODEL_CONFIG_PATH}" -maxdepth 1 -name \*.yml | sort) - MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" - if [ -n "${MODEL}" ]; then - writeConfigKey "productver" "${majorversion}.${minorversion}" "${USER_CONFIG_FILE}" - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - if [ -n "${PRODUCTVER}" ]; then - cp -f "${DSMROOT_PATH}/.syno/patch/zImage" "${PART2_PATH}" - cp -f "${DSMROOT_PATH}/.syno/patch/rd.gz" "${PART2_PATH}" - TEXT="Installation found:\nModel: ${MODEL}\nVersion: ${PRODUCTVER}" - SN=$(_get_conf_kv SN "${DSMROOT_PATH}/etc/synoinfo.conf") - if [ -n "${SN}" ]; then - deleteConfigKey "arc.patch" "${USER_CONFIG_FILE}" - SNARC="$(readConfigKey "arc.serial" "${MODEL_CONFIG_PATH}/${MODEL}.yml")" - writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}" - TEXT+="\nSerial: ${SN}" - if [ "${SN}" = "${SNARC}" ]; then - writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}" - else - writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" - fi - ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" - TEXT+="\nArc Patch: ${ARCPATCH}" - fi - dialog --backtitle "$(backtitle)" --title "Try to recover DSM" \ - --aspect 18 --msgbox "${TEXT}" 0 0 - ARCRECOVERY="true" - writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" - CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - arcbuild - fi - fi + if [ -f "${TMP_PATH}/mdX/usr/arc/backup/p1/user-config.yml" ]; then + cp -f "${TMP_PATH}/mdX/usr/arc/backup/p1/user-config.yml" "${USER_CONFIG_FILE}" + sleep 2 + MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" + if [[ -n "${MODEL}" && -n "${PRODUCTVER}" ]]; then + TEXT="Installation found:\nModel: ${MODEL}\nVersion: ${PRODUCTVER}" + SN="$(readConfigKey "arc.sn" "${USER_CONFIG_FILE}")" + TEXT+="\nSerial: ${SN}" + ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" + TEXT+="\nArc Patch: ${ARCPATCH}" + dialog --backtitle "$(backtitle)" --title "Try to recover DSM" \ + --aspect 18 --msgbox "${TEXT}" 0 0 + CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" fi fi + dialog --backtitle "$(backtitle)" --title "Try recovery DSM" --aspect 18 \ + --msgbox "Recovery completed!\nBuild Loader and Boot." 0 0 else dialog --backtitle "$(backtitle)" --title "Try recovery DSM" --aspect 18 \ --msgbox "Unfortunately Arc couldn't mount the DSM partition!" 0 0 @@ -734,8 +714,8 @@ function backupMenu() { --infobox "Backup Encryption Key..." 0 0 if [ -f "${PART2_PATH}/machine.key" ]; then if findAndMountDSMRoot; then - mkdir -p "${DSMROOT_PATH}/root/Xpenology_backup" - cp -f "${PART2_PATH}/machine.key" "${DSMROOT_PATH}/root/Xpenology_backup/machine.key" + mkdir -p "${TMP_PATH}/mdX/usr/arc/backup/p2" + cp -f "${PART2_PATH}/machine.key" "${TMP_PATH}/mdX/usr/arc/backup/p2/machine.key" dialog --backtitle "$(backtitle)" --title "Backup Encryption Key" --aspect 18 \ --msgbox "Encryption Key backup successful!" 0 0 else @@ -751,8 +731,8 @@ function backupMenu() { dialog --backtitle "$(backtitle)" --title "Restore Encryption Key" --aspect 18 \ --infobox "Restore Encryption Key..." 0 0 if findAndMountDSMRoot; then - if [ -f "${DSMROOT_PATH}/root/Xpenology_backup/machine.key" ]; then - cp -f "${DSMROOT_PATH}/root/Xpenology_backup/machine.key" "${PART2_PATH}/machine.key" + if [ -f "${TMP_PATH}/mdX/usr/arc/backup/p2/machine.key" ]; then + cp -f "${TMP_PATH}/mdX/usr/arc/backup/p2/machine.key" "${PART2_PATH}/machine.key" dialog --backtitle "$(backtitle)" --title "Restore Encryption Key" --aspect 18 \ --msgbox "Encryption Key restore successful!" 0 0 else @@ -770,7 +750,8 @@ function backupMenu() { while true; do dialog --backtitle "$(backtitle)" --menu "Choose an Option" 0 0 0 \ 1 "Recover from DSM" \ - 2 "Restore Encryption Key" \ + 2 "Backup Encryption Key" \ + 3 "Restore Encryption Key" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 case "$(cat ${TMP_PATH}/resp)" in @@ -780,64 +761,55 @@ function backupMenu() { if findAndMountDSMRoot; then MODEL="" PRODUCTVER="" - if [ -f "${DSMROOT_PATH}/.syno/patch/VERSION" ]; then - eval $(cat ${DSMROOT_PATH}/.syno/patch/VERSION | grep unique) - eval $(cat ${DSMROOT_PATH}/.syno/patch/VERSION | grep majorversion) - eval $(cat ${DSMROOT_PATH}/.syno/patch/VERSION | grep minorversion) - if [ -n "${unique}" ] ; then - while read -r F; do - M="$(basename ${F})" - M="${M::-4}" - UNIQUE="$(readModelKey "${M}" "unique")" - [ "${unique}" = "${UNIQUE}" ] || continue - # Found - writeConfigKey "model" "${M}" "${USER_CONFIG_FILE}" - done <<<$(find "${MODEL_CONFIG_PATH}" -maxdepth 1 -name \*.yml | sort) - MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" - if [ -n "${MODEL}" ]; then - writeConfigKey "productver" "${majorversion}.${minorversion}" "${USER_CONFIG_FILE}" - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - if [ -n "${PRODUCTVER}" ]; then - cp -f "${DSMROOT_PATH}/.syno/patch/zImage" "${PART2_PATH}" - cp -f "${DSMROOT_PATH}/.syno/patch/rd.gz" "${PART2_PATH}" - TEXT="Installation found:\nModel: ${MODEL}\nVersion: ${PRODUCTVER}" - SN=$(_get_conf_kv SN "${DSMROOT_PATH}/etc/synoinfo.conf") - if [ -n "${SN}" ]; then - deleteConfigKey "arc.patch" "${USER_CONFIG_FILE}" - SNARC="$(readConfigKey "arc.serial" "${MODEL_CONFIG_PATH}/${MODEL}.yml")" - writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}" - TEXT+="\nSerial: ${SN}" - if [ "${SN}" = "${SNARC}" ]; then - writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}" - else - writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" - fi - ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" - TEXT+="\nArc Patch: ${ARCPATCH}" - fi - dialog --backtitle "$(backtitle)" --title "Try to recover DSM" \ - --aspect 18 --msgbox "${TEXT}" 0 0 - ARCRECOVERY="true" - writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" - CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - arcbuild - fi - fi + if [ -f "${TMP_PATH}/mdX/usr/arc/backup/p1/user-config.yml" ]; then + cp -f "${TMP_PATH}/mdX/usr/arc/backup/p1/user-config.yml" "${USER_CONFIG_FILE}" + sleep 2 + MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" + if [[ -n "${MODEL}" && -n "${PRODUCTVER}" ]]; then + TEXT="Installation found:\nModel: ${MODEL}\nVersion: ${PRODUCTVER}" + SN="$(readConfigKey "arc.sn" "${USER_CONFIG_FILE}")" + TEXT+="\nSerial: ${SN}" + ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" + TEXT+="\nArc Patch: ${ARCPATCH}" + dialog --backtitle "$(backtitle)" --title "Try to recover DSM" \ + --aspect 18 --msgbox "${TEXT}" 0 0 + CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" fi fi + dialog --backtitle "$(backtitle)" --title "Try recovery DSM" --aspect 18 \ + --msgbox "Recovery completed!\nBuild Loader and Boot." 0 0 else dialog --backtitle "$(backtitle)" --title "Try recovery DSM" --aspect 18 \ --msgbox "Unfortunately Arc couldn't mount the DSM partition!" 0 0 fi ;; 2) + dialog --backtitle "$(backtitle)" --title "Backup Encryption Key" --aspect 18 \ + --infobox "Backup Encryption Key..." 0 0 + if [ -f "${PART2_PATH}/machine.key" ]; then + if findAndMountDSMRoot; then + mkdir -p "${TMP_PATH}/mdX/usr/arc/backup/p2" + cp -f "${PART2_PATH}/machine.key" "${TMP_PATH}/mdX/usr/arc/backup/p2/machine.key" + dialog --backtitle "$(backtitle)" --title "Backup Encryption Key" --aspect 18 \ + --msgbox "Encryption Key backup successful!" 0 0 + else + dialog --backtitle "$(backtitle)" --title "Backup Encryption Key" --aspect 18 \ + --msgbox "Unfortunately Arc couldn't mount the DSM Partition for Backup!" 0 0 + fi + else + dialog --backtitle "$(backtitle)" --title "Backup Encryption Key" --aspect 18 \ + --msgbox "No Encryption Key found!" 0 0 + fi + ;; + 3) dialog --backtitle "$(backtitle)" --title "Restore Encryption Key" --aspect 18 \ --infobox "Restore Encryption Key..." 0 0 if findAndMountDSMRoot; then - if [ -f "${DSMROOT_PATH}/root/Xpenology_backup/machine.key" ]; then - cp -f "${DSMROOT_PATH}/root/Xpenology_backup/machine.key" "${PART2_PATH}/machine.key" + if [ -f "${TMP_PATH}/mdX/usr/arc/backup/p2/machine.key" ]; then + cp -f "${TMP_PATH}/mdX/usr/arc/backup/p2/machine.key" "${PART2_PATH}/machine.key" dialog --backtitle "$(backtitle)" --title "Restore Encryption Key" --aspect 18 \ --msgbox "Encryption Key restore successful!" 0 0 else @@ -882,7 +854,7 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -s https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [[ $? -ne 0 || -z "${TAG}" ]]; then dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ --msgbox "Error checking new Version!" 0 0 @@ -903,7 +875,7 @@ function updateMenu() { [ $? -ne 0 ] && return 1 fi # Download update file - STATUS=$(curl --insecure -w "%{http_code}" -L "https://github.com/AuxXxilium/arc/releases/download/${TAG}/arc-${TAG}.img.zip" -o "${TMP_PATH}/arc-${TAG}.img.zip") + STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc/releases/download/${TAG}/arc-${TAG}.img.zip" -o "${TMP_PATH}/arc-${TAG}.img.zip") if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ --msgbox "Error downloading Updatefile!" 0 0 @@ -913,28 +885,20 @@ function updateMenu() { rm -f "${TMP_PATH}/arc-${TAG}.img.zip" if [ $? -ne 0 ]; then dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --msgbox "Error extracting Updatefile" 0 0 + --msgbox "Error extracting Updatefile!" 0 0 return 1 fi - if [[ -f "${USER_CONFIG_FILE}" && "${CONFDONE}" = "true" ]]; then - GENHASH="$(cat "${USER_CONFIG_FILE}" | curl -s -F "content=<-" http://dpaste.com/api/v2/ | cut -c 19-)" - dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --msgbox "Backup config successful!\nWrite down your Code: ${GENHASH}\n\nAfter Reboot use: Restore with Code." 0 0 - else - dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --msgbox "No config for Backup found!" 0 0 - fi dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --infobox "Installing new Loader Image" 0 0 + --infobox "Installing new Loader Image..." 0 0 # Process complete update umount "${PART1_PATH}" "${PART2_PATH}" "${PART3_PATH}" dd if="${TMP_PATH}/arc.img" of=$(blkid | grep 'LABEL="ARC3"' | cut -d3 -f1) bs=1M conv=fsync # Ask for Boot rm -f "${TMP_PATH}/arc.img" dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ - --yesno "Arc Upgrade successful. New Version: ${TAG}\nReboot?" 0 0 + --yesno "Arc Upgrade successful. New Version: ${TAG}\nUse Recover from DSM to get your old Config.\nReboot?" 0 0 [ $? -ne 0 ] && return 1 - exec reboot + rebootTo config exit 0 ;; 2) @@ -948,7 +912,7 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -s https://api.github.com/repos/AuxXxilium/arc-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [[ $? -ne 0 || -z "${TAG}" ]]; then dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ --msgbox "Error checking new Version!" 0 0 @@ -999,7 +963,7 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -s https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [[ $? -ne 0 || -z "${TAG}" ]]; then dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ --msgbox "Error checking new Version!" 0 0 @@ -1041,7 +1005,7 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -s https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [[ $? -ne 0 || -z "${TAG}" ]]; then dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ --msgbox "Error checking new Version!" 0 0 @@ -1097,7 +1061,7 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -s https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [[ $? -ne 0 || -z "${TAG}" ]]; then dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ --msgbox "Error checking new Version!" 0 0 @@ -1139,7 +1103,7 @@ function updateMenu() { opts=$(cat ${TMP_PATH}/opts) [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then - TAG="$(curl --insecure -s https://api.github.com/repos/AuxXxilium/redpill-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/redpill-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" if [[ $? -ne 0 || -z "${TAG}" ]]; then dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ --msgbox "Error checking new Version!" 0 0 @@ -1173,6 +1137,7 @@ function updateMenu() { ;; esac done + return } ############################################################################### @@ -1187,6 +1152,7 @@ function storageMenu() { fi writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + return } ############################################################################### @@ -1196,6 +1162,7 @@ function networkMenu() { getnet writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + return } ############################################################################### @@ -1235,7 +1202,6 @@ function sysinfo() { ARCIPV6="$(readConfigKey "arc.ipv6" "${USER_CONFIG_FILE}")" CONFIGVER="$(readConfigKey "arc.version" "${USER_CONFIG_FILE}")" HDDSORT="$(readConfigKey "arc.hddsort" "${USER_CONFIG_FILE}")" - KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" EXTERNALCONTROLLER="$(readConfigKey "device.externalcontroller" "${USER_CONFIG_FILE}")" HARDDRIVES="$(readConfigKey "device.harddrives" "${USER_CONFIG_FILE}")" DRIVES="$(readConfigKey "device.drives" "${USER_CONFIG_FILE}")" @@ -1306,7 +1272,6 @@ function sysinfo() { TEXT+="\n IPv6: \Zb${ARCIPV6}\Zn" TEXT+="\n Offline Mode: \Zb${OFFLINE}\Zn" TEXT+="\n Sort Drives: \Zb${HDDSORT}\Zn" - TEXT+="\n VMM/KVM Support: \Zb${KVMSUPPORT}\Zn" if [[ "${REMAP}" = "acports" || "${REMAP}" = "maxports" ]]; then TEXT+="\n SataPortMap | DiskIdxMap: \Zb${PORTMAP} | ${DISKMAP}\Zn" elif [ "${REMAP}" = "remap" ]; then @@ -1427,6 +1392,7 @@ function sysinfo() { return 0 ;; esac + return } function fullsysinfo() { @@ -1464,7 +1430,6 @@ function fullsysinfo() { ARCIPV6="$(readConfigKey "arc.ipv6" "${USER_CONFIG_FILE}")" CONFIGVER="$(readConfigKey "arc.version" "${USER_CONFIG_FILE}")" HDDSORT="$(readConfigKey "arc.hddsort" "${USER_CONFIG_FILE}")" - KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" EXTERNALCONTROLLER="$(readConfigKey "device.externalcontroller" "${USER_CONFIG_FILE}")" HARDDRIVES="$(readConfigKey "device.harddrives" "${USER_CONFIG_FILE}")" DRIVES="$(readConfigKey "device.drives" "${USER_CONFIG_FILE}")" @@ -1544,7 +1509,6 @@ function fullsysinfo() { TEXT+="\nIPv6: ${ARCIPV6}" TEXT+="\nOffline Mode: ${OFFLINE}" TEXT+="\nSort Drives: ${HDDSORT}" - TEXT+="\nVMM/KVM Support: ${KVMSUPPORT}" if [[ "${REMAP}" = "acports" || "${REMAP}" = "maxports" ]]; then TEXT+="\nSataPortMap | DiskIdxMap: ${PORTMAP} | ${DISKMAP}" elif [ "${REMAP}" = "remap" ]; then @@ -1666,6 +1630,7 @@ function fullsysinfo() { return 0 ;; esac + return } ############################################################################### @@ -1712,6 +1677,7 @@ function networkdiag() { fi dialog --backtitle "$(backtitle)" --colors --title "Networkdiag" \ --msgbox "${MSG}" 0 0 + return } ############################################################################### @@ -1741,6 +1707,7 @@ function credits() { TEXT+="\n" dialog --backtitle "$(backtitle)" --colors --title "Credits" \ --msgbox "${TEXT}" 0 0 + return } ############################################################################### @@ -1799,6 +1766,7 @@ function staticIPMenu() { done dialog --backtitle "$(backtitle)" --title "DHCP/StaticIP" \ --msgbox "Settings written and enabled.\nThis will be not applied to DSM." 5 50 + return } ############################################################################### @@ -1811,86 +1779,97 @@ function downgradeMenu() { dialog --backtitle "$(backtitle)" --title "Allow downgrade installation" \ --yesno "${TEXT}" 0 0 [ $? -ne 0 ] && return 1 - ( - mkdir -p "${TMP_PATH}/sdX1" - # for I in $(ls /dev/sd*1 2>/dev/null | grep -v "${LOADER_DISK_PART1}"); do - for I in $(blkid 2>/dev/null | grep -i linux_raid_member | grep -E "/dev/.*1: " | awk -F ":" '{print $1}'); do - mount "${I}" "${TMP_PATH}/sdX1" - [ -f "${TMP_PATH}/sdX1/etc/VERSION" ] && rm -f "${TMP_PATH}/sdX1/etc/VERSION" - [ -f "${TMP_PATH}/sdX1/etc.defaults/VERSION" ] && rm -f "${TMP_PATH}/sdX1/etc.defaults/VERSION" - sync - umount "${I}" - done - rm -rf "${TMP_PATH}/sdX1" - ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Allow downgrade installation" \ + if [ -z "$(ls /dev/md/*:0 2>/dev/null)" ]; then # SynologyNAS:0, DiskStation:0, SynologyNVR:0, BeeStation:0 + dialog --backtitle "$(backtitle)" --title "Allow downgrade installation" \ + --msgbox "No DSM system partition(md0) found!\nPlease insert all disks before continuing." 0 0 + return 1 + fi + while true; do + mkdir -p "${TMP_PATH}/mdX" + mount "$(ls /dev/md/*:0 2>/dev/null | head -n 1)" "${TMP_PATH}/mdX" + [ $? -ne 0 ] && break + [ -f "${TMP_PATH}/mdX/etc/VERSION" ] && rm -f "${TMP_PATH}/mdX/etc/VERSION" + [ -f "${TMP_PATH}/mdX/etc.defaults/VERSION" ] && rm -f "${TMP_PATH}/mdX/etc.defaults/VERSION" + sync + umount "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" + break + done 2>&1 | dialog --backtitle "$(backtitle)" --title "Allow downgrade installation" \ --progressbox "Removing ..." 20 70 TEXT="Remove VERSION file for all disks completed." dialog --backtitle "$(backtitle)" --colors --aspect 18 \ --msgbox "${TEXT}" 0 0 + return } ############################################################################### # Reset DSM password function resetPassword() { + if [ -z "$(ls /dev/md/*:0 2>/dev/null)" ]; then # SynologyNAS:0, DiskStation:0, SynologyNVR:0, BeeStation:0 + dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ + --msgbox "No DSM system partition(md0) found!\nPlease insert all disks before continuing." 0 0 + return + fi rm -f "${TMP_PATH}/menu" - mkdir -p "${TMP_PATH}/sdX1" - for I in $(blkid 2>/dev/null | grep -i linux_raid_member | grep -E "/dev/.*1: " | awk -F ":" '{print $1}'); do - mount ${I} "${TMP_PATH}/sdX1" - if [ -f "${TMP_PATH}/sdX1/etc/shadow" ]; then - while read -r L; do + while true; do + mkdir -p "${TMP_PATH}/mdX" + mount "$(ls /dev/md/*:0 2>/dev/null | head -n 1)" "${TMP_PATH}/mdX" + [ $? -ne 0 ] && break + if [ -f "${TMP_PATH}/mdX/etc/shadow" ]; then + while read L; do U=$(echo "${L}" | awk -F ':' '{if ($2 != "*" && $2 != "!!") print $1;}') [ -z "${U}" ] && continue E=$(echo "${L}" | awk -F ':' '{if ($8 == "1") print "disabled"; else print " ";}') - grep -q "status=on" "${TMP_PATH}/sdX1/usr/syno/etc/packages/SecureSignIn/preference/${U}/method.config" 2>/dev/null + grep -q "status=on" "${TMP_PATH}/mdX/usr/syno/etc/packages/SecureSignIn/preference/${U}/method.config" 2>/dev/null [ $? -eq 0 ] && S="SecureSignIn" || S=" " printf "\"%-36s %-10s %-14s\"\n" "${U}" "${E}" "${S}" >>"${TMP_PATH}/menu" - done <<<$(cat "${TMP_PATH}/sdX1/etc/shadow") + done <<<$(cat "${TMP_PATH}/mdX/etc/shadow" 2>/dev/null) fi - umount "${I}" - [ -f "${TMP_PATH}/menu" ] && break + umount "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" + break done - rm -rf "${TMP_PATH}/sdX1" if [ ! -f "${TMP_PATH}/menu" ]; then dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ - --msgbox "The installed Syno system not found in the currently inserted disks!" 0 0 - return 1 + --msgbox "All existing users have been disabled. Please try adding new user." 0 0 + return fi dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ - --no-items --menu "Choose a User" 0 0 0 --file "${TMP_PATH}/menu" \ + --no-items --menu "Choose a user name" 0 0 0 --file "${TMP_PATH}/menu" \ 2>${TMP_PATH}/resp - [ $? -ne 0 ] && return 1 - USER="$(cat "${TMP_PATH}/resp" | awk '{print $1}')" - [ -z "${USER}" ] && return 1 + [ $? -ne 0 ] && return + USER="$(cat "${TMP_PATH}/resp" 2>/dev/null | awk '{print $1}')" + [ -z "${USER}" ] && return while true; do dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ - --inputbox "Type a new Password for User ${USER}" 0 70 "${CMDLINE[${NAME}]}" \ + --inputbox "Type a new password for user ${USER}" 0 70 "${CMDLINE[${NAME}]}" \ 2>${TMP_PATH}/resp [ $? -ne 0 ] && break 2 - VALUE=$(cat "${TMP_PATH}/resp") + VALUE="$(cat "${TMP_PATH}/resp")" [ -n "${VALUE}" ] && break dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ - --msgbox "Invalid Password" 0 0 + --msgbox "Invalid password" 0 0 done NEWPASSWD="$(python -c "from passlib.hash import sha512_crypt;pw=\"${VALUE}\";print(sha512_crypt.using(rounds=5000).hash(pw))")" - ( - mkdir -p "${TMP_PATH}/sdX1" - # for I in $(ls /dev/sd*1 2>/dev/null | grep -v "${LOADER_DISK_PART1}"); do - for I in $(blkid 2>/dev/null | grep -i linux_raid_member | grep -E "/dev/.*1: " | awk -F ":" '{print $1}'); do - mount "${I}" "${TMP_PATH}/sdX1" - OLDPASSWD="$(cat "${TMP_PATH}/sdX1/etc/shadow" 2>/dev/null | grep "^${USER}:" | awk -F ':' '{print $2}')" - if [ -n "${NEWPASSWD}" -a -n "${OLDPASSWD}" ]; then - sed -i "s|${OLDPASSWD}|${NEWPASSWD}|g" "${TMP_PATH}/sdX1/etc/shadow" - sed -i "/^${USER}:/ s/\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\)/\1:\2:\3:\4:\5:\6:\7::\9/" "${TMP_PATH}/sdX1/etc/shadow" - fi - sed -i "s|status=on|status=off|g" "${TMP_PATH}/sdX1/usr/syno/etc/packages/SecureSignIn/preference/${USER}/method.config" 2>/dev/null - sync - umount "${I}" - done - rm -rf "${TMP_PATH}/sdX1" - ) 2>&1 | dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ + while true; do + mkdir -p "${TMP_PATH}/mdX" + mount "$(ls /dev/md/*:0 2>/dev/null | head -n 1)" "${TMP_PATH}/mdX" + [ $? -ne 0 ] && break + OLDPASSWD="$(cat "${TMP_PATH}/mdX/etc/shadow" 2>/dev/null | grep "^${USER}:" | awk -F ':' '{print $2}')" + if [ -n "${NEWPASSWD}" -a -n "${OLDPASSWD}" ]; then + sed -i "s|${OLDPASSWD}|${NEWPASSWD}|g" "${TMP_PATH}/mdX/etc/shadow" + sed -i "/^${USER}:/ s/\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\):\([^:]*\)/\1:\2:\3:\4:\5:\6:\7::\9/" "${TMP_PATH}/mdX/etc/shadow" + fi + sed -i "s|status=on|status=off|g" "${TMP_PATH}/mdX/usr/syno/etc/packages/SecureSignIn/preference/${USER}/method.config" 2>/dev/null + sync + umount "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" + break + done 2>&1 | dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ --progressbox "Resetting ..." 20 100 - dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" --aspect 18 \ + dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ --msgbox "Password reset completed." 0 0 + return } ############################################################################### @@ -1923,6 +1902,7 @@ function saveMenu() { rm -rf "${RDXZ_PATH}" dialog --backtitle "$(backtitle)" --colors --aspect 18 \ --msgbox "Save to Disk is complete." 0 0 + return } ############################################################################### @@ -1970,6 +1950,7 @@ function formatdisks() { --progressbox "Formatting ..." 20 100 dialog --backtitle "$(backtitle)" --colors --title "Format Disks" \ --msgbox "Formatting is complete." 0 0 + return } ############################################################################### @@ -1986,6 +1967,7 @@ function package() { --progressbox "Installing opkg ..." 20 100 dialog --backtitle "$(backtitle)" --colors --title "Package" \ --msgbox "Installation is complete.\nPlease reconnect to ssh/web,\nor execute 'source ~/.bashrc'" 0 0 + return } ############################################################################### @@ -1998,11 +1980,12 @@ function forcessh() { ONBOOTUP="" ONBOOTUP="${ONBOOTUP}synowebapi --exec api=SYNO.Core.Terminal method=set version=3 enable_telnet=true enable_ssh=true ssh_port=22 forbid_console=false\n" ONBOOTUP="${ONBOOTUP}echo \"DELETE FROM task WHERE task_name LIKE ''ARCONBOOTUPARC'';\" | sqlite3 /usr/syno/etc/esynoscheduler/esynoscheduler.db\n" - mkdir -p "${TMP_PATH}/sdX1" - for I in $(blkid 2>/dev/null | grep -i linux_raid_member | grep -E "/dev/.*1: " | awk -F ":" '{print $1}'); do - mount "${I}" "${TMP_PATH}/sdX1" - if [ -f "${TMP_PATH}/sdX1/usr/syno/etc/esynoscheduler/esynoscheduler.db" ]; then - sqlite3 ${TMP_PATH}/sdX1/usr/syno/etc/esynoscheduler/esynoscheduler.db </dev/null | head -n 1)" "${TMP_PATH}/mdX" + [ $? -ne 0 ] && break + if [ -f "${TMP_PATH}/mdX/usr/syno/etc/esynoscheduler/esynoscheduler.db" ]; then + sqlite3 ${TMP_PATH}/mdX/usr/syno/etc/esynoscheduler/esynoscheduler.db <${TMP_PATH}/isEnable fi - umount "${I}" + umount "${TMP_PATH}/mdX" + rm -rf "${TMP_PATH}/mdX" + break done - rm -rf "${TMP_PATH}/sdX1" ) 2>&1 | dialog --backtitle "$(backtitle)" --colors --title "Force SSH" \ --progressbox "Enabling ..." 20 100 [ "$(cat ${TMP_PATH}/isEnable 2>/dev/null)" = "true" ] && MSG="Telnet&SSH is enabled." || MSG="Telnet&SSH is not enabled." dialog --backtitle "$(backtitle)" --colors --title "Force SSH" \ --msgbox "${MSG}" 0 0 + return } ############################################################################### @@ -2117,6 +2102,7 @@ function editGrubCfg() { mv -f "${TMP_PATH}/usergrub.cfg" "${GRUB_PATH}/grub.cfg" break done + return } ############################################################################### @@ -2145,6 +2131,7 @@ function greplogs() { dialog --backtitle "$(backtitle)" --colors --title "Grep Logs" \ --msgbox "${MSG}" 0 0 fi + return } ############################################################################### @@ -2173,4 +2160,5 @@ function getbackup() { dialog --backtitle "$(backtitle)" --colors --title "DSM Config" \ --msgbox "${MSG}" 0 0 fi + return } \ No newline at end of file diff --git a/files/initrd/opt/arc/arc.sh b/files/initrd/opt/arc/arc.sh index fc5b2979..b733f096 100755 --- a/files/initrd/opt/arc/arc.sh +++ b/files/initrd/opt/arc/arc.sh @@ -62,7 +62,6 @@ ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" BOOTIPWAIT="$(readConfigKey "arc.bootipwait" "${USER_CONFIG_FILE}")" KERNELLOAD="$(readConfigKey "arc.kernelload" "${USER_CONFIG_FILE}")" KERNELPANIC="$(readConfigKey "arc.kernelpanic" "${USER_CONFIG_FILE}")" -KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")" ODP="$(readConfigKey "arc.odp" "${USER_CONFIG_FILE}")" MODULESCOPY="$(readConfigKey "arc.modulescopy" "${USER_CONFIG_FILE}")" @@ -73,6 +72,7 @@ ARCIPV6="$(readConfigKey "arc.ipv6" "${USER_CONFIG_FILE}")" EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")" OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" EXTERNALCONTROLLER="$(readConfigKey "device.externalcontroller" "${USER_CONFIG_FILE}")" +CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")" # Get Config/Build Status CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" @@ -264,6 +264,7 @@ function arcVersion() { # Build isn't done writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + return 0 fi } @@ -396,14 +397,6 @@ function arcSettings() { dialog --backtitle "$(backtitle)" --title "Arc Warning" \ --msgbox "WARN: Your CPU does not have AES Support for Hardwareencryption in DSM." 0 0 fi - # Check for KVM - KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" - if [ "${KVMSUPPORT}" = "true" ]; then - if ! grep -q -E '(vmx|svm)' /proc/cpuinfo; then - dialog --backtitle "$(backtitle)" --title "Arc Warning" \ - --msgbox "WARN: Your CPU does not support KVM in DSM.\nCheck CPU/Bios for VMX or SVM Support." 0 0 - fi - fi # Config is done writeConfigKey "arc.confdone" "true" "${USER_CONFIG_FILE}" CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" @@ -434,23 +427,10 @@ function premake() { DT="$(readModelKey "${MODEL}" "dt")" # Read Config for Arc Settings USBMOUNT="$(readConfigKey "arc.usbmount" "${USER_CONFIG_FILE}")" - KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")" # Memory: Set mem_max_mb to the amount of installed memory to bypass Limitation writeConfigKey "synoinfo.mem_max_mb" "${RAMMAX}" "${USER_CONFIG_FILE}" writeConfigKey "synoinfo.mem_min_mb" "${RAMMIN}" "${USER_CONFIG_FILE}" - # KVM Support - if [ "${KVMSUPPORT}" = "true" ]; then - writeConfigKey "modules.kvm_intel" "" "${USER_CONFIG_FILE}" - writeConfigKey "modules.kvm_amd" "" "${USER_CONFIG_FILE}" - writeConfigKey "modules.kvm" "" "${USER_CONFIG_FILE}" - writeConfigKey "modules.irgbypass" "" "${USER_CONFIG_FILE}" - else - deleteConfigKey "modules.kvm_intel" "${USER_CONFIG_FILE}" - deleteConfigKey "modules.kvm_amd" "${USER_CONFIG_FILE}" - deleteConfigKey "modules.kvm" "${USER_CONFIG_FILE}" - deleteConfigKey "modules.irgbypass" "${USER_CONFIG_FILE}" - fi # eMMC Boot Support if [ "${EMMCBOOT}" = "true" ]; then writeConfigKey "modules.mmc_block" "" "${USER_CONFIG_FILE}" @@ -493,7 +473,6 @@ function arcSummary() { OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" ARCIPV6="$(readConfigKey "arc.ipv6" "${USER_CONFIG_FILE}")" HDDSORT="$(readConfigKey "arc.hddsort" "${USER_CONFIG_FILE}")" - KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" NIC="$(readConfigKey "device.nic" "${USER_CONFIG_FILE}")" EXTERNALCONTROLLER="$(readConfigKey "device.externalcontroller" "${USER_CONFIG_FILE}")" HARDDRIVES="$(readConfigKey "device.harddrives" "${USER_CONFIG_FILE}")" @@ -518,7 +497,6 @@ function arcSummary() { SUMMARY+="\n>> USB Mount: \Zb${USBMOUNT}\Zn" SUMMARY+="\n>> Sort Drives: \Zb${HDDSORT}\Zn" SUMMARY+="\n>> IPv6: \Zb${ARCIPV6}\Zn" - SUMMARY+="\n>> KVM Support: \Zb${KVMSUPPORT}\Zn" SUMMARY+="\n>> Offline Mode: \Zb${OFFLINE}\Zn" SUMMARY+="\n>> Directboot: \Zb${DIRECTBOOT}\Zn" SUMMARY+="\n>> eMMC Boot: \Zb${EMMCBOOT}\Zn" @@ -858,303 +836,568 @@ function boot() { exec reboot } +############################################################################### +# Make Model Config +function arcAutomated() { + # read model config for dt and aes + MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" + DT="$(readModelKey "${MODEL}" "dt")" + ARCCONF="$(readModelKey "${M}" "arc.serial")" + [ -n "${ARCCONF}" ] && ARCPATCH="true" || ARCPATCH="false" + if [ "${ARCPATCH}" = "true" ]; then + SN="$(readModelKey "${MODEL}" "arc.serial")" + writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}" + elif [ "${ARCPATCH}" = "false" ]; then + SN="$(generateSerial "${MODEL}")" + writeConfigKey "arc.sn" "${SN}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" + fi + ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" + PLATFORM="$(readModelKey "${MODEL}" "platform")" + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" + KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" + if [ "${PLATFORM}" = "epyc7002" ]; then + KVER="${PRODUCTVER}-${KVER}" + fi + writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + if [[ -f "${ORI_ZIMAGE_FILE}" || -f "${ORI_RDGZ_FILE}" || -f "${MOD_ZIMAGE_FILE}" || -f "${MOD_RDGZ_FILE}" ]]; then + # Delete old files + rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" + fi + dialog --backtitle "$(backtitle)" --title "Arc Config" \ + --infobox "Reconfiguring Synoinfo and Modules" 3 40 + # Reset synoinfo + writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}" + while IFS=': ' read -r KEY VALUE; do + writeConfigKey "synoinfo.\"${KEY}\"" "${VALUE}" "${USER_CONFIG_FILE}" + done <<<$(readModelMap "${MODEL}" "productvers.[${PRODUCTVER}].synoinfo") + # Reset modules + writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" + while read -r ID DESC; do + writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" + done <<<$(getAllModules "${PLATFORM}" "${KVER}") + # Check for ACPI Support + if ! grep -q "^flags.*acpi.*" /proc/cpuinfo; then + deleteConfigKey "addons.acpid" "${USER_CONFIG_FILE}" + fi + autoarcSettings +} + +############################################################################### +# Arc Settings Section +function autoarcSettings() { + # Get Network Config for Loader + dialog --backtitle "$(backtitle)" --colors --title "Network Config" \ + --infobox "Network Config..." 3 30 + autogetnet + # Select Portmap for Loader (nonDT) + getmap + if [[ "${DT}" = "false" && $(lspci -d ::106 | wc -l) -gt 0 ]]; then + dialog --backtitle "$(backtitle)" --colors --title "Storage Map" \ + --infobox "Storage Map..." 3 30 + autogetmapSelection + fi + # Config is done + writeConfigKey "arc.confdone" "true" "${USER_CONFIG_FILE}" + CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" + autopremake +} + +############################################################################### +# Building Loader Online +function autopremake() { + # Read Model Config + MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" + PLATFORM="$(readModelKey "${MODEL}" "platform")" + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" + KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" + DT="$(readModelKey "${MODEL}" "dt")" + # Read Config for Arc Settings + USBMOUNT="$(readConfigKey "arc.usbmount" "${USER_CONFIG_FILE}")" + KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" + EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")" + # Memory: Set mem_max_mb to the amount of installed memory to bypass Limitation + writeConfigKey "synoinfo.mem_max_mb" "${RAMMAX}" "${USER_CONFIG_FILE}" + writeConfigKey "synoinfo.mem_min_mb" "${RAMMIN}" "${USER_CONFIG_FILE}" + # KVM Support + if [ "${KVMSUPPORT}" = "true" ]; then + writeConfigKey "modules.kvm_intel" "" "${USER_CONFIG_FILE}" + writeConfigKey "modules.kvm_amd" "" "${USER_CONFIG_FILE}" + writeConfigKey "modules.kvm" "" "${USER_CONFIG_FILE}" + writeConfigKey "modules.irgbypass" "" "${USER_CONFIG_FILE}" + else + deleteConfigKey "modules.kvm_intel" "${USER_CONFIG_FILE}" + deleteConfigKey "modules.kvm_amd" "${USER_CONFIG_FILE}" + deleteConfigKey "modules.kvm" "${USER_CONFIG_FILE}" + deleteConfigKey "modules.irgbypass" "${USER_CONFIG_FILE}" + fi + # eMMC Boot Support + if [ "${EMMCBOOT}" = "true" ]; then + writeConfigKey "modules.mmc_block" "" "${USER_CONFIG_FILE}" + writeConfigKey "modules.mmc_core" "" "${USER_CONFIG_FILE}" + else + deleteConfigKey "modules.mmc_block" "${USER_CONFIG_FILE}" + deleteConfigKey "modules.mmc_core" "${USER_CONFIG_FILE}" + fi + # Fixes for SA6400 + if [ "${PLATFORM}" = "epyc7002" ]; then + KVER="${PRODUCTVER}-${KVER}" + MODULESCOPY="false" + writeConfigKey "arc.modulescopy" "${MODULESCOPY}" "${USER_CONFIG_FILE}" + fi + # Build Loader + automake +} + +############################################################################### +# Building Loader Online +function automake() { + # Read Model Config + MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" + PLATFORM="$(readModelKey "${MODEL}" "platform")" + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" + KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" + DT="$(readModelKey "${MODEL}" "dt")" + OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" + if [ "${PLATFORM}" = "epyc7002" ]; then + KVER="${PRODUCTVER}-${KVER}" + fi + # Cleanup + if [ -d "${UNTAR_PAT_PATH}" ]; then + rm -rf "${UNTAR_PAT_PATH}" + fi + mkdir -p "${UNTAR_PAT_PATH}" + # Check if all addon exists + while IFS=': ' read -r ADDON PARAM; do + [ -z "${ADDON}" ] && continue + if ! checkAddonExist "${ADDON}" "${PLATFORM}" "${KVER}"; then + deleteConfigKey "addons.${ADDON}" "${USER_CONFIG_FILE}" + continue + fi + done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}") + dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \ + --infobox "Get PAT Data from Syno..." 3 30 + # Get PAT Data from Syno + idx=0 + while [ ${idx} -le 3 ]; do # Loop 3 times, if successful, break + PAT_URL="$(curl -m 5 -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 5 -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 + break + fi + sleep 3 + idx=$((${idx} + 1)) + done + if [[ -z "${PAT_URL}" || -z "${PAT_HASH}" ]]; then + dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \ + --infobox "Syno Connection failed,\ntry to get from Github..." 4 30 + 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%%.*}.${PRODUCTVER##*.}/pat_url")" + PAT_HASH="$(curl -m 5 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER%%.*}.${PRODUCTVER##*.}/pat_hash")" + PAT_URL=${PAT_URL%%\?*} + if [[ -n "${PAT_URL}" && -n "${PAT_HASH}" ]]; then + break + fi + sleep 3 + idx=$((${idx} + 1)) + done + fi + if [[ -z "${PAT_URL}" || -z "${PAT_HASH}" ]]; then + dialog --backtitle "$(backtitle)" --title "DSM Data" --aspect 18 \ + --infobox "No DSM Data found!\nExit." 0 0 + sleep 5 + return 1 + else + dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \ + --infobox "Get PAT Data sucessfull..." 3 30 + fi + 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}" + # Check for existing Files + 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" + STATUS=$(curl --insecure -s -w "%{http_code}" -L "${DSM_URL}" -o "${DSM_FILE}") + if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then + dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \ + --infobox "No DSM Image found!\nTry Syno Link." 0 0 + # Grep PAT_URL + PAT_FILE="${TMP_PATH}/${PAT_HASH}.pat" + STATUS=$(curl -k -w "%{http_code}" -L "${PAT_URL}" -o "${PAT_FILE}" --progress-bar) + if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then + dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \ + --infobox "No DSM Image found!\ Exit." 0 0 + sleep 5 + return 1 + fi + # Extract Files + header=$(od -bcN2 ${PAT_FILE} | head -1 | awk '{print $3}') + case ${header} in + 105) + isencrypted="no" + ;; + 213) + isencrypted="no" + ;; + 255) + isencrypted="yes" + ;; + *) + echo -e "Could not determine if pat file is encrypted or not, maybe corrupted, try again!" + ;; + esac + if [ "${isencrypted}" = "yes" ]; then + # Uses the extractor to untar PAT file + LD_LIBRARY_PATH="${EXTRACTOR_PATH}" "${EXTRACTOR_PATH}/${EXTRACTOR_BIN}" "${PAT_FILE}" "${UNTAR_PAT_PATH}" + else + # Untar PAT file + tar -xf "${PAT_FILE}" -C "${UNTAR_PAT_PATH}" >"${LOG_FILE}" 2>&1 + fi + # Cleanup PAT Download + rm -f "${PAT_FILE}" + elif [ -f "${DSM_FILE}" ]; then + tar -xf "${DSM_FILE}" -C "${UNTAR_PAT_PATH}" >"${LOG_FILE}" 2>&1 + elif [ ! -f "${UNTAR_PAT_PATH}/zImage" ]; then + dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \ + --infobox "ERROR: No DSM Image found!" 0 0 + sleep 5 + return 1 + fi + dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \ + --infobox "Image unpack sucessfull..." 3 30 + # Copy DSM Files to Locations if DSM Files not found + cp -f "${UNTAR_PAT_PATH}/grub_cksum.syno" "${PART1_PATH}" + cp -f "${UNTAR_PAT_PATH}/GRUB_VER" "${PART1_PATH}" + cp -f "${UNTAR_PAT_PATH}/grub_cksum.syno" "${PART2_PATH}" + cp -f "${UNTAR_PAT_PATH}/GRUB_VER" "${PART2_PATH}" + cp -f "${UNTAR_PAT_PATH}/zImage" "${ORI_ZIMAGE_FILE}" + cp -f "${UNTAR_PAT_PATH}/rd.gz" "${ORI_RDGZ_FILE}" + rm -rf "${UNTAR_PAT_PATH}" + fi + ( + livepatch + sleep 3 + ) 2>&1 | dialog --backtitle "$(backtitle)" --colors --title "Build Loader" \ + --progressbox "Doing the Magic..." 20 70 + if [[ -f "${ORI_ZIMAGE_FILE}" && -f "${ORI_RDGZ_FILE}" && -f "${MOD_ZIMAGE_FILE}" && -f "${MOD_RDGZ_FILE}" ]]; then + # Build is done + writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + boot && exit 0 + fi +} + ############################################################################### ############################################################################### # Main loop -[ "${BUILDDONE}" = "true" ] && NEXT="3" || NEXT="1" -while true; do - echo "= \"\Z4========== Main ==========\Zn \" " >"${TMP_PATH}/menu" - echo "1 \"Choose Model \" " >>"${TMP_PATH}/menu" - if [ "${CONFDONE}" = "true" ]; then - echo "2 \"Build Loader \" " >>"${TMP_PATH}/menu" - fi - if [ "${BUILDDONE}" = "true" ]; then - echo "3 \"Boot Loader \" " >>"${TMP_PATH}/menu" - fi - echo "= \"\Z4========== Info ==========\Zn \" " >>"${TMP_PATH}/menu" - echo "a \"Sysinfo \" " >>"${TMP_PATH}/menu" - echo "A \"Networkdiag \" " >>"${TMP_PATH}/menu" - echo "= \"\Z4========= System =========\Zn \" " >>"${TMP_PATH}/menu" - if [ "${CONFDONE}" = "true" ]; then - if [ "${ARCOPTS}" = "true" ]; then - echo "4 \"\Z1Hide Arc Options\Zn \" " >>"${TMP_PATH}/menu" - else - echo "4 \"\Z1Show Arc Options\Zn \" " >>"${TMP_PATH}/menu" +if grep -q "automated_arc" /proc/cmdline; then + arcAutomated +else + [ "${BUILDDONE}" = "true" ] && NEXT="3" || NEXT="1" + while true; do + echo "= \"\Z4========== Main ==========\Zn \" " >"${TMP_PATH}/menu" + echo "1 \"Choose Model \" " >>"${TMP_PATH}/menu" + if [ "${CONFDONE}" = "true" ]; then + echo "2 \"Build Loader \" " >>"${TMP_PATH}/menu" fi - if [ "${ARCOPTS}" = "true" ]; then - echo "= \"\Z4========== Arc ==========\Zn \" " >>"${TMP_PATH}/menu" - echo "b \"Addons \" " >>"${TMP_PATH}/menu" - echo "d \"Modules \" " >>"${TMP_PATH}/menu" - echo "e \"DSM Version \" " >>"${TMP_PATH}/menu" - echo "p \"Arc Patch Settings \" " >>"${TMP_PATH}/menu" - echo "N \"Network Config \" " >>"${TMP_PATH}/menu" - echo "S \"Change Storage Map \" " >>"${TMP_PATH}/menu" - echo "P \"Custom StoragePanel \" " >>"${TMP_PATH}/menu" - echo "D \"Loader DHCP/StaticIP \" " >>"${TMP_PATH}/menu" + if [ "${BUILDDONE}" = "true" ]; then + echo "3 \"Boot Loader \" " >>"${TMP_PATH}/menu" fi - if [ "${ADVOPTS}" = "true" ]; then - echo "5 \"\Z1Hide Advanced Options\Zn \" " >>"${TMP_PATH}/menu" - else - echo "5 \"\Z1Show Advanced Options\Zn \" " >>"${TMP_PATH}/menu" - fi - if [ "${ADVOPTS}" = "true" ]; then - echo "= \"\Z4======== Advanced =======\Zn \" " >>"${TMP_PATH}/menu" - echo "j \"Cmdline \" " >>"${TMP_PATH}/menu" - echo "k \"Synoinfo \" " >>"${TMP_PATH}/menu" - echo "l \"Edit User Config \" " >>"${TMP_PATH}/menu" - echo "w \"Reset Loader \" " >>"${TMP_PATH}/menu" - fi - if [ "${BOOTOPTS}" = "true" ]; then - echo "6 \"\Z1Hide Boot Options\Zn \" " >>"${TMP_PATH}/menu" - else - echo "6 \"\Z1Show Boot Options\Zn \" " >>"${TMP_PATH}/menu" - fi - if [ "${BOOTOPTS}" = "true" ]; then - echo "= \"\Z4========== Boot =========\Zn \" " >>"${TMP_PATH}/menu" - echo "m \"DSM Kernelload: \Z4${KERNELLOAD}\Zn \" " >>"${TMP_PATH}/menu" - if [ "${DIRECTBOOT}" = "false" ]; then - echo "i \"Boot IP Waittime: \Z4${BOOTIPWAIT}\Zn \" " >>"${TMP_PATH}/menu" + echo "= \"\Z4========== Info ==========\Zn \" " >>"${TMP_PATH}/menu" + echo "a \"Sysinfo \" " >>"${TMP_PATH}/menu" + echo "A \"Networkdiag \" " >>"${TMP_PATH}/menu" + echo "= \"\Z4========= System =========\Zn \" " >>"${TMP_PATH}/menu" + if [ "${CONFDONE}" = "true" ]; then + if [ "${ARCOPTS}" = "true" ]; then + echo "4 \"\Z1Hide Arc Options\Zn \" " >>"${TMP_PATH}/menu" + else + echo "4 \"\Z1Show Arc Options\Zn \" " >>"${TMP_PATH}/menu" + fi + if [ "${ARCOPTS}" = "true" ]; then + echo "= \"\Z4========== Arc ==========\Zn \" " >>"${TMP_PATH}/menu" + echo "b \"Addons \" " >>"${TMP_PATH}/menu" + echo "d \"Modules \" " >>"${TMP_PATH}/menu" + echo "e \"DSM Version \" " >>"${TMP_PATH}/menu" + echo "p \"Arc Patch Settings \" " >>"${TMP_PATH}/menu" + echo "N \"Change Network Config \" " >>"${TMP_PATH}/menu" + echo "S \"Change Storage Map \" " >>"${TMP_PATH}/menu" + echo "P \"Custom StoragePanel \" " >>"${TMP_PATH}/menu" + echo "D \"Loader DHCP/StaticIP \" " >>"${TMP_PATH}/menu" + echo "R \"Automated: \Z4${CUSTOM}\Zn \" " >>"${TMP_PATH}/menu" + fi + if [ "${ADVOPTS}" = "true" ]; then + echo "5 \"\Z1Hide Advanced Options\Zn \" " >>"${TMP_PATH}/menu" + else + echo "5 \"\Z1Show Advanced Options\Zn \" " >>"${TMP_PATH}/menu" + fi + if [ "${ADVOPTS}" = "true" ]; then + echo "= \"\Z4======== Advanced =======\Zn \" " >>"${TMP_PATH}/menu" + echo "j \"Cmdline \" " >>"${TMP_PATH}/menu" + echo "k \"Synoinfo \" " >>"${TMP_PATH}/menu" + echo "l \"Edit User Config \" " >>"${TMP_PATH}/menu" + echo "w \"Reset Loader \" " >>"${TMP_PATH}/menu" + fi + if [ "${BOOTOPTS}" = "true" ]; then + echo "6 \"\Z1Hide Boot Options\Zn \" " >>"${TMP_PATH}/menu" + else + echo "6 \"\Z1Show Boot Options\Zn \" " >>"${TMP_PATH}/menu" + fi + if [ "${BOOTOPTS}" = "true" ]; then + echo "= \"\Z4========== Boot =========\Zn \" " >>"${TMP_PATH}/menu" + echo "m \"DSM Kernelload: \Z4${KERNELLOAD}\Zn \" " >>"${TMP_PATH}/menu" + if [ "${DIRECTBOOT}" = "false" ]; then + echo "i \"Boot IP Waittime: \Z4${BOOTIPWAIT}\Zn \" " >>"${TMP_PATH}/menu" + fi + echo "q \"Directboot: \Z4${DIRECTBOOT}\Zn \" " >>"${TMP_PATH}/menu" + echo "J \"Boot DSM Reinstall Mode\" " >>"${TMP_PATH}/menu" + echo "I \"Boot DSM Recovery Mode\" " >>"${TMP_PATH}/menu" + fi + if [ "${DSMOPTS}" = "true" ]; then + echo "7 \"\Z1Hide DSM Options\Zn \" " >>"${TMP_PATH}/menu" + else + echo "7 \"\Z1Show DSM Options\Zn \" " >>"${TMP_PATH}/menu" + fi + if [ "${DSMOPTS}" = "true" ]; then + echo "= \"\Z4========== DSM ==========\Zn \" " >>"${TMP_PATH}/menu" + echo "s \"Allow DSM Downgrade \" " >>"${TMP_PATH}/menu" + echo "t \"Change DSM Password \" " >>"${TMP_PATH}/menu" + if [ "${MODEL}" = "SA6400" ]; then + echo "K \"Kernel: \Z4${KERNEL}\Zn \" " >>"${TMP_PATH}/menu" + fi + if [ ! "${MODEL}" = "SA6400" ]; then + echo "M \"Copy Modules to DSM: \Z4${MODULESCOPY}\Zn \" " >>"${TMP_PATH}/menu" + fi + echo "O \"Official Driver Priority: \Z4${ODP}\Zn \" " >>"${TMP_PATH}/menu" + echo "H \"Sort Drives: \Z4${HDDSORT}\Zn \" " >>"${TMP_PATH}/menu" + echo "U \"USB Mount: \Z4${USBMOUNT}\Zn \" " >>"${TMP_PATH}/menu" + echo "c \"IPv6 Support: \Z4${ARCIPV6}\Zn \" " >>"${TMP_PATH}/menu" + echo "E \"eMMC Boot Support: \Z4${EMMCBOOT}\Zn \" " >>"${TMP_PATH}/menu" + echo "o \"Switch MacSys: \Z4${MACSYS}\Zn \" " >>"${TMP_PATH}/menu" + echo "u \"Switch LKM version: \Z4${LKM}\Zn \" " >>"${TMP_PATH}/menu" fi - echo "q \"Directboot: \Z4${DIRECTBOOT}\Zn \" " >>"${TMP_PATH}/menu" - echo "J \"Boot DSM Reinstall Mode\" " >>"${TMP_PATH}/menu" - echo "I \"Boot DSM Recovery Mode\" " >>"${TMP_PATH}/menu" fi - if [ "${DSMOPTS}" = "true" ]; then - echo "7 \"\Z1Hide DSM Options\Zn \" " >>"${TMP_PATH}/menu" + if [ "${DEVOPTS}" = "true" ]; then + echo "8 \"\Z1Hide Dev Options\Zn \" " >>"${TMP_PATH}/menu" else - echo "7 \"\Z1Show DSM Options\Zn \" " >>"${TMP_PATH}/menu" + echo "8 \"\Z1Show Dev Options\Zn \" " >>"${TMP_PATH}/menu" fi - if [ "${DSMOPTS}" = "true" ]; then - echo "= \"\Z4========== DSM ==========\Zn \" " >>"${TMP_PATH}/menu" - echo "s \"Allow DSM Downgrade \" " >>"${TMP_PATH}/menu" - echo "t \"Change DSM Password \" " >>"${TMP_PATH}/menu" - if [ "${MODEL}" = "SA6400" ]; then - echo "K \"Kernel: \Z4${KERNEL}\Zn \" " >>"${TMP_PATH}/menu" - fi - if [ ! "${MODEL}" = "SA6400" ]; then - echo "M \"Copy Modules to DSM: \Z4${MODULESCOPY}\Zn \" " >>"${TMP_PATH}/menu" - fi - echo "O \"Official Driver Priority: \Z4${ODP}\Zn \" " >>"${TMP_PATH}/menu" - echo "H \"Sort Drives: \Z4${HDDSORT}\Zn \" " >>"${TMP_PATH}/menu" - echo "U \"USB Mount: \Z4${USBMOUNT}\Zn \" " >>"${TMP_PATH}/menu" - echo "V \"KVM Support: \Z4${KVMSUPPORT}\Zn \" " >>"${TMP_PATH}/menu" - echo "c \"IPv6 Support: \Z4${ARCIPV6}\Zn \" " >>"${TMP_PATH}/menu" - echo "E \"eMMC Boot Support: \Z4${EMMCBOOT}\Zn \" " >>"${TMP_PATH}/menu" - echo "o \"Switch MacSys: \Z4${MACSYS}\Zn \" " >>"${TMP_PATH}/menu" - echo "u \"Switch LKM version: \Z4${LKM}\Zn \" " >>"${TMP_PATH}/menu" + if [ "${DEVOPTS}" = "true" ]; then + echo "= \"\Z4========== Dev ===========\Zn \" " >>"${TMP_PATH}/menu" + echo "v \"Save Modifications to Disk \" " >>"${TMP_PATH}/menu" + echo "n \"Edit Grub Config \" " >>"${TMP_PATH}/menu" + echo "B \"Get DSM Config Backup \" " >>"${TMP_PATH}/menu" + echo "L \"Grep Logs from dbgutils \" " >>"${TMP_PATH}/menu" + echo "T \"Force enable SSH in DSM \" " >>"${TMP_PATH}/menu" + echo "C \"Clone Loaderdisk \" " >>"${TMP_PATH}/menu" + echo "F \"\Z1Format Sata/NVMe Disk\Zn \" " >>"${TMP_PATH}/menu" + echo "G \"Install opkg Package Manager \" " >>"${TMP_PATH}/menu" fi - fi - if [ "${DEVOPTS}" = "true" ]; then - echo "8 \"\Z1Hide Dev Options\Zn \" " >>"${TMP_PATH}/menu" - else - echo "8 \"\Z1Show Dev Options\Zn \" " >>"${TMP_PATH}/menu" - fi - if [ "${DEVOPTS}" = "true" ]; then - echo "= \"\Z4========== Dev ===========\Zn \" " >>"${TMP_PATH}/menu" - echo "v \"Save Modifications to Disk \" " >>"${TMP_PATH}/menu" - echo "n \"Edit Grub Config \" " >>"${TMP_PATH}/menu" - echo "B \"Get DSM Config Backup \" " >>"${TMP_PATH}/menu" - echo "L \"Grep Logs from dbgutils \" " >>"${TMP_PATH}/menu" - echo "T \"Force enable SSH in DSM \" " >>"${TMP_PATH}/menu" - echo "C \"Clone Loaderdisk \" " >>"${TMP_PATH}/menu" - echo "F \"\Z1Format Sata/NVMe Disk\Zn \" " >>"${TMP_PATH}/menu" - echo "G \"Install opkg Package Manager \" " >>"${TMP_PATH}/menu" - fi - echo "= \"\Z4====== Misc Settings =====\Zn \" " >>"${TMP_PATH}/menu" - echo "x \"Backup/Restore/Recovery \" " >>"${TMP_PATH}/menu" - echo "9 \"Offline Mode: \Z4${OFFLINE}\Zn \" " >>"${TMP_PATH}/menu" - echo "y \"Choose a Keymap \" " >>"${TMP_PATH}/menu" - if [ "${OFFLINE}" = "false" ]; then - echo "z \"Update \" " >>"${TMP_PATH}/menu" - fi - echo "0 \"Credits \" " >>"${TMP_PATH}/menu" + echo "= \"\Z4====== Misc Settings =====\Zn \" " >>"${TMP_PATH}/menu" + echo "x \"Backup/Restore/Recovery \" " >>"${TMP_PATH}/menu" + echo "9 \"Offline Mode: \Z4${OFFLINE}\Zn \" " >>"${TMP_PATH}/menu" + echo "y \"Choose a Keymap \" " >>"${TMP_PATH}/menu" + if [ "${OFFLINE}" = "false" ]; then + echo "z \"Update \" " >>"${TMP_PATH}/menu" + fi + echo "V \"Credits \" " >>"${TMP_PATH}/menu" - dialog --clear --default-item ${NEXT} --backtitle "$(backtitle)" --colors \ - --cancel-label "Exit" --title "Arc Menu" --menu "" 0 0 0 --file "${TMP_PATH}/menu" \ - 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && break - case "$(cat ${TMP_PATH}/resp)" in - # Main Section - 1) arcModel; NEXT="2" ;; - 2) premake; NEXT="3" ;; - 3) boot && exit 0 ;; - # Info Section - a) sysinfo; NEXT="a" ;; - A) networkdiag; NEXT="A" ;; - # System Section - # Arc Section - 4) [ "${ARCOPTS}" = "true" ] && ARCOPTS='false' || ARCOPTS='true' - ARCOPTS="${ARCOPTS}" - NEXT="4" - ;; - b) addonMenu; NEXT="b" ;; - d) modulesMenu; NEXT="d" ;; - e) ONLYVERSION="true" && arcVersion; NEXT="e" ;; - N) networkMenu; NEXT="N" ;; - S) storageMenu; NEXT="S" ;; - p) ONLYPATCH="true" && arcPatch; NEXT="p" ;; - P) storagepanelMenu; NEXT="P" ;; - D) staticIPMenu; NEXT="D" ;; - # Advanced Section - 5) [ "${ADVOPTS}" = "true" ] && ADVOPTS='false' || ADVOPTS='true' - ADVOPTS="${ADVOPTS}" - NEXT="5" - ;; - j) cmdlineMenu; NEXT="j" ;; - k) synoinfoMenu; NEXT="k" ;; - l) editUserConfig; NEXT="l" ;; - w) resetLoader; NEXT="w" ;; - # Boot Section - 6) [ "${BOOTOPTS}" = "true" ] && BOOTOPTS='false' || BOOTOPTS='true' - ARCOPTS="${BOOTOPTS}" - NEXT="6" - ;; - m) [ "${KERNELLOAD}" = "kexec" ] && KERNELLOAD='power' || KERNELLOAD='kexec' - writeConfigKey "arc.kernelload" "${KERNELLOAD}" "${USER_CONFIG_FILE}" - NEXT="m" - ;; - i) bootipwaittime; NEXT="i" ;; - q) [ "${DIRECTBOOT}" = "false" ] && DIRECTBOOT='true' || DIRECTBOOT='false' - grub-editenv "${GRUB_PATH}/grubenv" create - writeConfigKey "arc.directboot" "${DIRECTBOOT}" "${USER_CONFIG_FILE}" - NEXT="q" - ;; - J) juniorboot; NEXT="J" ;; - I) recoveryboot; NEXT="I" ;; - # DSM Section - 7) [ "${DSMOPTS}" = "true" ] && DSMOPTS='false' || DSMOPTS='true' - DSMOPTS="${DSMOPTS}" - NEXT="7" - ;; - s) downgradeMenu; NEXT="s" ;; - t) resetPassword; NEXT="t" ;; - K) [ "${KERNEL}" = "official" ] && KERNEL='custom' || KERNEL='official' - writeConfigKey "arc.kernel" "${KERNEL}" "${USER_CONFIG_FILE}" - if [ "${ODP}" = "true" ]; then - ODP="false" + dialog --clear --default-item ${NEXT} --backtitle "$(backtitle)" --colors \ + --cancel-label "Exit" --title "Arc Menu" --menu "" 0 0 0 --file "${TMP_PATH}/menu" \ + 2>"${TMP_PATH}/resp" + [ $? -ne 0 ] && break + case "$(cat ${TMP_PATH}/resp)" in + # Main Section + 1) arcModel; NEXT="2" ;; + 2) premake; NEXT="3" ;; + 3) boot && exit 0 ;; + # Info Section + a) sysinfo; NEXT="a" ;; + A) networkdiag; NEXT="A" ;; + # System Section + # Arc Section + 4) [ "${ARCOPTS}" = "true" ] && ARCOPTS='false' || ARCOPTS='true' + ARCOPTS="${ARCOPTS}" + NEXT="4" + ;; + b) addonMenu; NEXT="b" ;; + d) modulesMenu; NEXT="d" ;; + e) ONLYVERSION="true" && arcVersion; NEXT="e" ;; + N) networkMenu; NEXT="N" ;; + S) storageMenu; NEXT="S" ;; + p) ONLYPATCH="true" && arcPatch; NEXT="p" ;; + P) storagepanelMenu; NEXT="P" ;; + D) staticIPMenu; NEXT="D" ;; + R) [ "${CUSTOM}" = "false" ] && CUSTOM='true' || CUSTOM='false' + writeConfigKey "arc.custom" "${CUSTOM}" "${USER_CONFIG_FILE}" + if [ "${CUSTOM}" = "true" ]; then + [ ! -f "${PART3_PATH}/automated" ] && echo "${ARC_VERSION}-${MODEL}-{PRODUCTVER}-custom" >"${PART3_PATH}/automated" + elif [ "${CUSTOM}" = "false" ]; then + [ -f "${PART3_PATH}/automated" ] && rm -f "${PART3_PATH}/automated" + fi + NEXT="R" + ;; + # Advanced Section + 5) [ "${ADVOPTS}" = "true" ] && ADVOPTS='false' || ADVOPTS='true' + ADVOPTS="${ADVOPTS}" + NEXT="5" + ;; + j) cmdlineMenu; NEXT="j" ;; + k) synoinfoMenu; NEXT="k" ;; + l) editUserConfig; NEXT="l" ;; + w) resetLoader; NEXT="w" ;; + # Boot Section + 6) [ "${BOOTOPTS}" = "true" ] && BOOTOPTS='false' || BOOTOPTS='true' + ARCOPTS="${BOOTOPTS}" + NEXT="6" + ;; + m) [ "${KERNELLOAD}" = "kexec" ] && KERNELLOAD='power' || KERNELLOAD='kexec' + writeConfigKey "arc.kernelload" "${KERNELLOAD}" "${USER_CONFIG_FILE}" + NEXT="m" + ;; + i) bootipwaittime; NEXT="i" ;; + q) [ "${DIRECTBOOT}" = "false" ] && DIRECTBOOT='true' || DIRECTBOOT='false' + grub-editenv "${GRUB_PATH}/grubenv" create + writeConfigKey "arc.directboot" "${DIRECTBOOT}" "${USER_CONFIG_FILE}" + NEXT="q" + ;; + J) juniorboot; NEXT="J" ;; + I) recoveryboot; NEXT="I" ;; + # DSM Section + 7) [ "${DSMOPTS}" = "true" ] && DSMOPTS='false' || DSMOPTS='true' + DSMOPTS="${DSMOPTS}" + NEXT="7" + ;; + s) downgradeMenu; NEXT="s" ;; + t) resetPassword; NEXT="t" ;; + K) [ "${KERNEL}" = "official" ] && KERNEL='custom' || KERNEL='official' + writeConfigKey "arc.kernel" "${KERNEL}" "${USER_CONFIG_FILE}" + if [ "${ODP}" = "true" ]; then + ODP="false" + writeConfigKey "arc.odp" "${ODP}" "${USER_CONFIG_FILE}" + fi + if [ "${MODULESCOPY}" = "true" ]; then + MODULESCOPY="false" + writeConfigKey "arc.modulescopy" "${MODULESCOPY}" "${USER_CONFIG_FILE}" + fi + PLATFORM="$(readModelKey "${MODEL}" "platform")" + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" + KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" + if [ "${PLATFORM}" = "epyc7002" ]; then + KVER="${PRODUCTVER}-${KVER}" + fi + if [[ -n "${PLATFORM}" && -n "${KVER}" ]]; then + writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" + while read -r ID DESC; do + writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" + done <<<$(getAllModules "${PLATFORM}" "${KVER}") + fi + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="K" + ;; + O) [ "${ODP}" = "false" ] && ODP='true' || ODP='false' writeConfigKey "arc.odp" "${ODP}" "${USER_CONFIG_FILE}" - fi - if [ "${MODULESCOPY}" = "true" ]; then - MODULESCOPY="false" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="O" + ;; + M) [ "${MODULESCOPY}" = "false" ] && MODULESCOPY='true' || MODULESCOPY='false' writeConfigKey "arc.modulescopy" "${MODULESCOPY}" "${USER_CONFIG_FILE}" - fi - PLATFORM="$(readModelKey "${MODEL}" "platform")" - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" - if [ "${PLATFORM}" = "epyc7002" ]; then - KVER="${PRODUCTVER}-${KVER}" - fi - if [[ -n "${PLATFORM}" && -n "${KVER}" ]]; then - writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read -r ID DESC; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "${KVER}") - fi - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="K" - ;; - O) [ "${ODP}" = "false" ] && ODP='true' || ODP='false' - writeConfigKey "arc.odp" "${ODP}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="O" - ;; - M) [ "${MODULESCOPY}" = "false" ] && MODULESCOPY='true' || MODULESCOPY='false' - writeConfigKey "arc.modulescopy" "${MODULESCOPY}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="M" - ;; - H) [ "${HDDSORT}" = "true" ] && HDDSORT='false' || HDDSORT='true' - writeConfigKey "arc.hddsort" "${HDDSORT}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="H" - ;; - U) - if [ "${USBMOUNT}" = "true" ]; then - USBMOUNT="false" - elif [[ "${USBMOUNT}" = "false" && "${DT}" = "false" ]]; then - USBMOUNT="force" - elif [[ "${USBMOUNT}" = "force" || "${USBMOUNT}" = "false" ]]; then - USBMOUNT="true" - fi - writeConfigKey "arc.usbmount" "${USBMOUNT}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="U" - ;; - V) [ "${KVMSUPPORT}" = "true" ] && KVMSUPPORT='false' || KVMSUPPORT='true' - writeConfigKey "arc.kvm" "${KVMSUPPORT}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="V" - ;; - c) [ "${ARCIPV6}" = "true" ] && ARCIPV6='false' || ARCIPV6='true' - writeConfigKey "arc.ipv6" "${ARCIPV6}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="c" - ;; - E) [ "${EMMCBOOT}" = "true" ] && EMMCBOOT='false' || EMMCBOOT='true' - if [ "${EMMCBOOT}" = "false" ]; then - writeConfigKey "arc.emmcboot" "false" "${USER_CONFIG_FILE}" - deleteConfigKey "synoinfo.disk_swap" "${USER_CONFIG_FILE}" - deleteConfigKey "synoinfo.supportraid" "${USER_CONFIG_FILE}" - deleteConfigKey "synoinfo.support_emmc_boot" "${USER_CONFIG_FILE}" - deleteConfigKey "synoinfo.support_install_only_dev" "${USER_CONFIG_FILE}" - elif [ "${EMMCBOOT}" = "true" ]; then - writeConfigKey "arc.emmcboot" "true" "${USER_CONFIG_FILE}" - writeConfigKey "synoinfo.disk_swap" "no" "${USER_CONFIG_FILE}" - writeConfigKey "synoinfo.supportraid" "no" "${USER_CONFIG_FILE}" - writeConfigKey "synoinfo.support_emmc_boot" "yes" "${USER_CONFIG_FILE}" - writeConfigKey "synoinfo.support_install_only_dev" "yes" "${USER_CONFIG_FILE}" - fi - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="E" - ;; - o) [ "${MACSYS}" = "hardware" ] && MACSYS='custom' || MACSYS='hardware' - writeConfigKey "arc.macsys" "${MACSYS}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="o" - ;; - u) [ "${LKM}" = "prod" ] && LKM='dev' || LKM='prod' - writeConfigKey "lkm" "${LKM}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="u" - ;; - # Dev Section - 8) [ "${DEVOPTS}" = "true" ] && DEVOPTS='false' || DEVOPTS='true' - DEVOPTS="${DEVOPTS}" - NEXT="8" - ;; - v) saveMenu; NEXT="v" ;; - n) editGrubCfg; NEXT="n" ;; - B) getbackup; NEXT="B" ;; - L) greplogs; NEXT="L" ;; - T) forcessh; NEXT="T" ;; - C) cloneLoader; NEXT="C" ;; - F) formatdisks; NEXT="F" ;; - G) package; NEXT="G" ;; - # Loader Settings - x) backupMenu; NEXT="x" ;; - 9) [ "${OFFLINE}" = "true" ] && OFFLINE='false' || OFFLINE='true' - OFFLINE="${OFFLINE}" - writeConfigKey "arc.offline" "${OFFLINE}" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - NEXT="9" - ;; - y) keymapMenu; NEXT="y" ;; - z) updateMenu; NEXT="z" ;; - 0) credits; NEXT="0" ;; - esac -done -clear + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="M" + ;; + H) [ "${HDDSORT}" = "true" ] && HDDSORT='false' || HDDSORT='true' + writeConfigKey "arc.hddsort" "${HDDSORT}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="H" + ;; + U) + if [ "${USBMOUNT}" = "true" ]; then + USBMOUNT="false" + elif [[ "${USBMOUNT}" = "false" && "${DT}" = "false" ]]; then + USBMOUNT="force" + elif [[ "${USBMOUNT}" = "force" || "${USBMOUNT}" = "false" ]]; then + USBMOUNT="true" + fi + writeConfigKey "arc.usbmount" "${USBMOUNT}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="U" + ;; + c) [ "${ARCIPV6}" = "true" ] && ARCIPV6='false' || ARCIPV6='true' + writeConfigKey "arc.ipv6" "${ARCIPV6}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="c" + ;; + E) [ "${EMMCBOOT}" = "true" ] && EMMCBOOT='false' || EMMCBOOT='true' + if [ "${EMMCBOOT}" = "false" ]; then + writeConfigKey "arc.emmcboot" "false" "${USER_CONFIG_FILE}" + deleteConfigKey "synoinfo.disk_swap" "${USER_CONFIG_FILE}" + deleteConfigKey "synoinfo.supportraid" "${USER_CONFIG_FILE}" + deleteConfigKey "synoinfo.support_emmc_boot" "${USER_CONFIG_FILE}" + deleteConfigKey "synoinfo.support_install_only_dev" "${USER_CONFIG_FILE}" + elif [ "${EMMCBOOT}" = "true" ]; then + writeConfigKey "arc.emmcboot" "true" "${USER_CONFIG_FILE}" + writeConfigKey "synoinfo.disk_swap" "no" "${USER_CONFIG_FILE}" + writeConfigKey "synoinfo.supportraid" "no" "${USER_CONFIG_FILE}" + writeConfigKey "synoinfo.support_emmc_boot" "yes" "${USER_CONFIG_FILE}" + writeConfigKey "synoinfo.support_install_only_dev" "yes" "${USER_CONFIG_FILE}" + fi + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="E" + ;; + o) [ "${MACSYS}" = "hardware" ] && MACSYS='custom' || MACSYS='hardware' + writeConfigKey "arc.macsys" "${MACSYS}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="o" + ;; + u) [ "${LKM}" = "prod" ] && LKM='dev' || LKM='prod' + writeConfigKey "lkm" "${LKM}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="u" + ;; + # Dev Section + 8) [ "${DEVOPTS}" = "true" ] && DEVOPTS='false' || DEVOPTS='true' + DEVOPTS="${DEVOPTS}" + NEXT="8" + ;; + v) saveMenu; NEXT="v" ;; + n) editGrubCfg; NEXT="n" ;; + B) getbackup; NEXT="B" ;; + L) greplogs; NEXT="L" ;; + T) forcessh; NEXT="T" ;; + C) cloneLoader; NEXT="C" ;; + F) formatdisks; NEXT="F" ;; + G) package; NEXT="G" ;; + # Loader Settings + x) backupMenu; NEXT="x" ;; + 9) [ "${OFFLINE}" = "true" ] && OFFLINE='false' || OFFLINE='true' + OFFLINE="${OFFLINE}" + writeConfigKey "arc.offline" "${OFFLINE}" "${USER_CONFIG_FILE}" + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + NEXT="9" + ;; + y) keymapMenu; NEXT="y" ;; + z) updateMenu; NEXT="z" ;; + V) credits; NEXT="V" ;; + esac + done + clear +fi # Inform user echo -e "Call \033[1;34marc.sh\033[0m to configure Loader" @@ -1165,4 +1408,4 @@ echo -e "User: \033[1;34mroot\033[0m" echo -e "Password: \033[1;34marc\033[0m" echo echo -e "Web Terminal:" -echo -e "Address: \033[1;34mhttp://${IPCON}:7681\033[0m" +echo -e "Address: \033[1;34mhttp://${IPCON}:7681\033[0m" \ No newline at end of file diff --git a/files/initrd/opt/arc/automated.sh b/files/initrd/opt/arc/automated.sh deleted file mode 100755 index 2b7fa59b..00000000 --- a/files/initrd/opt/arc/automated.sh +++ /dev/null @@ -1,377 +0,0 @@ -#!/usr/bin/env bash - -############################################################################### -# Overlay Init Section -[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" - -. ${ARC_PATH}/include/functions.sh -. ${ARC_PATH}/include/addons.sh -. ${ARC_PATH}/include/modules.sh -. ${ARC_PATH}/include/storage_automated.sh -. ${ARC_PATH}/include/network_automated.sh -. ${ARC_PATH}/arc-functions.sh - -[ -z "${LOADER_DISK}" ] && die "Loader Disk not found!" - -# Memory: Check Memory installed -RAMFREE=$(($(free -m | grep -i mem | awk '{print$2}') / 1024 + 1)) -RAMTOTAL=$((${RAMFREE} * 1024)) -[ -z "${RAMTOTAL}" ] || [ ${RAMTOTAL} -le 0 ] && RAMTOTAL=8192 -RAMMAX=$((${RAMTOTAL} * 2)) -RAMMIN=$((${RAMTOTAL} / 2)) - -# Check for Hypervisor -if grep -q "^flags.*hypervisor.*" /proc/cpuinfo; then - # Check for Hypervisor - MACHINE="$(lscpu | grep Hypervisor | awk '{print $3}')" -else - MACHINE="NATIVE" -fi - -# Get Loader Disk Bus -BUS=$(getBus "${LOADER_DISK}") - -# Get DSM Data from Config -MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" -PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" -LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")" -KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")" -LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")" -if [ -n "${MODEL}" ]; then - PLATFORM="$(readModelKey "${MODEL}" "platform")" - DT="$(readModelKey "${MODEL}" "dt")" -fi - -# Get Arc Data from Config -DIRECTBOOT="$(readConfigKey "arc.directboot" "${USER_CONFIG_FILE}")" -CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" -BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" -ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" -BOOTIPWAIT="$(readConfigKey "arc.bootipwait" "${USER_CONFIG_FILE}")" -KERNELLOAD="$(readConfigKey "arc.kernelload" "${USER_CONFIG_FILE}")" -KERNELPANIC="$(readConfigKey "arc.kernelpanic" "${USER_CONFIG_FILE}")" -KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" -MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")" -ODP="$(readConfigKey "arc.odp" "${USER_CONFIG_FILE}")" -MODULESCOPY="$(readConfigKey "arc.modulescopy" "${USER_CONFIG_FILE}")" -HDDSORT="$(readConfigKey "arc.hddsort" "${USER_CONFIG_FILE}")" -KERNEL="$(readConfigKey "arc.kernel" "${USER_CONFIG_FILE}")" -USBMOUNT="$(readConfigKey "arc.usbmount" "${USER_CONFIG_FILE}")" -ARCIPV6="$(readConfigKey "arc.ipv6" "${USER_CONFIG_FILE}")" -EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")" -OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" -EXTERNALCONTROLLER="$(readConfigKey "device.externalcontroller" "${USER_CONFIG_FILE}")" - -############################################################################### -# Mounts backtitle dynamically -function backtitle() { - if [ ! -n "${MODEL}" ]; then - MODEL="(Model)" - fi - if [ ! -n "${PRODUCTVER}" ]; then - PRODUCTVER="(Version)" - fi - if [ ! -n "${IPCON}" ]; then - IPCON="(IP)" - fi - BACKTITLE="${ARC_TITLE} | " - BACKTITLE+="${MODEL} | " - BACKTITLE+="${PRODUCTVER} | " - BACKTITLE+="${IPCON} | " - BACKTITLE+="Patch: ${ARCPATCH} | " - BACKTITLE+="Config: ${CONFDONE} | " - BACKTITLE+="Build: ${BUILDDONE} | " - BACKTITLE+="${MACHINE}(${BUS})" - echo "${BACKTITLE}" -} - -############################################################################### -# Make Model Config -function arcAutomated() { - # read model config for dt and aes - MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" - DT="$(readModelKey "${MODEL}" "dt")" - ARCCONF="$(readModelKey "${M}" "arc.serial")" - [ -n "${ARCCONF}" ] && ARCPATCH="true" || ARCPATCH="false" - if [ "${ARCPATCH}" = "true" ]; then - SN="$(readModelKey "${MODEL}" "arc.serial")" - writeConfigKey "arc.patch" "true" "${USER_CONFIG_FILE}" - elif [ "${ARCPATCH}" = "false" ]; then - SN="$(generateSerial "${MODEL}")" - writeConfigKey "arc.patch" "false" "${USER_CONFIG_FILE}" - fi - ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" - PLATFORM="$(readModelKey "${MODEL}" "platform")" - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" - if [ "${PLATFORM}" = "epyc7002" ]; then - KVER="${PRODUCTVER}-${KVER}" - fi - writeConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}" - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - if [[ -f "${ORI_ZIMAGE_FILE}" || -f "${ORI_RDGZ_FILE}" || -f "${MOD_ZIMAGE_FILE}" || -f "${MOD_RDGZ_FILE}" ]]; then - # Delete old files - rm -f "${ORI_ZIMAGE_FILE}" "${ORI_RDGZ_FILE}" "${MOD_ZIMAGE_FILE}" "${MOD_RDGZ_FILE}" - fi - dialog --backtitle "$(backtitle)" --title "Arc Config" \ - --infobox "Reconfiguring Synoinfo and Modules" 3 40 - # Reset synoinfo - writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}" - while IFS=': ' read -r KEY VALUE; do - writeConfigKey "synoinfo.\"${KEY}\"" "${VALUE}" "${USER_CONFIG_FILE}" - done <<<$(readModelMap "${MODEL}" "productvers.[${PRODUCTVER}].synoinfo") - # Reset modules - writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" - while read -r ID DESC; do - writeConfigKey "modules.\"${ID}\"" "" "${USER_CONFIG_FILE}" - done <<<$(getAllModules "${PLATFORM}" "${KVER}") - # Check for ACPI Support - if ! grep -q "^flags.*acpi.*" /proc/cpuinfo; then - deleteConfigKey "addons.acpid" "${USER_CONFIG_FILE}" - fi - arcSettings -} - -############################################################################### -# Arc Settings Section -function arcSettings() { - # Get Network Config for Loader - dialog --backtitle "$(backtitle)" --colors --title "Network Config" \ - --infobox "Network Config..." 3 30 - getnet - # Select Portmap for Loader (nonDT) - getmap - if [[ "${DT}" = "false" && $(lspci -d ::106 | wc -l) -gt 0 ]]; then - dialog --backtitle "$(backtitle)" --colors --title "Storage Map" \ - --infobox "Storage Map..." 3 30 - getmapSelection - fi - # Config is done - writeConfigKey "arc.confdone" "true" "${USER_CONFIG_FILE}" - CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" - premake -} - -############################################################################### -# Building Loader Online -function premake() { - # Read Model Config - MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" - PLATFORM="$(readModelKey "${MODEL}" "platform")" - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" - DT="$(readModelKey "${MODEL}" "dt")" - # Read Config for Arc Settings - USBMOUNT="$(readConfigKey "arc.usbmount" "${USER_CONFIG_FILE}")" - KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" - EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")" - # Memory: Set mem_max_mb to the amount of installed memory to bypass Limitation - writeConfigKey "synoinfo.mem_max_mb" "${RAMMAX}" "${USER_CONFIG_FILE}" - writeConfigKey "synoinfo.mem_min_mb" "${RAMMIN}" "${USER_CONFIG_FILE}" - # KVM Support - if [ "${KVMSUPPORT}" = "true" ]; then - writeConfigKey "modules.kvm_intel" "" "${USER_CONFIG_FILE}" - writeConfigKey "modules.kvm_amd" "" "${USER_CONFIG_FILE}" - writeConfigKey "modules.kvm" "" "${USER_CONFIG_FILE}" - writeConfigKey "modules.irgbypass" "" "${USER_CONFIG_FILE}" - else - deleteConfigKey "modules.kvm_intel" "${USER_CONFIG_FILE}" - deleteConfigKey "modules.kvm_amd" "${USER_CONFIG_FILE}" - deleteConfigKey "modules.kvm" "${USER_CONFIG_FILE}" - deleteConfigKey "modules.irgbypass" "${USER_CONFIG_FILE}" - fi - # eMMC Boot Support - if [ "${EMMCBOOT}" = "true" ]; then - writeConfigKey "modules.mmc_block" "" "${USER_CONFIG_FILE}" - writeConfigKey "modules.mmc_core" "" "${USER_CONFIG_FILE}" - else - deleteConfigKey "modules.mmc_block" "${USER_CONFIG_FILE}" - deleteConfigKey "modules.mmc_core" "${USER_CONFIG_FILE}" - fi - # Fixes for SA6400 - if [ "${PLATFORM}" = "epyc7002" ]; then - KVER="${PRODUCTVER}-${KVER}" - MODULESCOPY="false" - writeConfigKey "arc.modulescopy" "${MODULESCOPY}" "${USER_CONFIG_FILE}" - fi - # Build Loader - make -} - -############################################################################### -# Building Loader Online -function make() { - # Read Model Config - MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" - PLATFORM="$(readModelKey "${MODEL}" "platform")" - PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" - KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" - DT="$(readModelKey "${MODEL}" "dt")" - OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" - if [ "${PLATFORM}" = "epyc7002" ]; then - KVER="${PRODUCTVER}-${KVER}" - fi - # Cleanup - if [ -d "${UNTAR_PAT_PATH}" ]; then - rm -rf "${UNTAR_PAT_PATH}" - fi - mkdir -p "${UNTAR_PAT_PATH}" - # Check if all addon exists - while IFS=': ' read -r ADDON PARAM; do - [ -z "${ADDON}" ] && continue - if ! checkAddonExist "${ADDON}" "${PLATFORM}" "${KVER}"; then - deleteConfigKey "addons.${ADDON}" "${USER_CONFIG_FILE}" - continue - fi - done <<<$(readConfigMap "addons" "${USER_CONFIG_FILE}") - dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \ - --infobox "Get PAT Data from Syno..." 3 30 - # Get PAT Data from Syno - idx=0 - while [ ${idx} -le 3 ]; do # Loop 3 times, if successful, break - PAT_URL="$(curl -m 5 -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 5 -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 - break - fi - sleep 3 - idx=$((${idx} + 1)) - done - if [[ -z "${PAT_URL}" || -z "${PAT_HASH}" ]]; then - dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \ - --infobox "Syno Connection failed,\ntry to get from Github..." 4 30 - 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%%.*}.${PRODUCTVER##*.}/pat_url")" - PAT_HASH="$(curl -m 5 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER%%.*}.${PRODUCTVER##*.}/pat_hash")" - PAT_URL=${PAT_URL%%\?*} - if [[ -n "${PAT_URL}" && -n "${PAT_HASH}" ]]; then - break - fi - sleep 3 - idx=$((${idx} + 1)) - done - fi - if [[ -z "${PAT_URL}" || -z "${PAT_HASH}" ]]; then - dialog --backtitle "$(backtitle)" --title "DSM Data" --aspect 18 \ - --infobox "No DSM Data found!\nExit." 0 0 - sleep 5 - return 1 - else - dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \ - --infobox "Get PAT Data sucessfull..." 3 30 - fi - 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}" - # Check for existing Files - 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" - STATUS=$(curl --insecure -s -w "%{http_code}" -L "${DSM_URL}" -o "${DSM_FILE}") - if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then - dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \ - --infobox "No DSM Image found!\nTry Syno Link." 0 0 - # Grep PAT_URL - PAT_FILE="${TMP_PATH}/${PAT_HASH}.pat" - STATUS=$(curl -k -w "%{http_code}" -L "${PAT_URL}" -o "${PAT_FILE}" --progress-bar) - if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then - dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \ - --infobox "No DSM Image found!\ Exit." 0 0 - sleep 5 - return 1 - fi - # Extract Files - header=$(od -bcN2 ${PAT_FILE} | head -1 | awk '{print $3}') - case ${header} in - 105) - isencrypted="no" - ;; - 213) - isencrypted="no" - ;; - 255) - isencrypted="yes" - ;; - *) - echo -e "Could not determine if pat file is encrypted or not, maybe corrupted, try again!" - ;; - esac - if [ "${isencrypted}" = "yes" ]; then - # Uses the extractor to untar PAT file - LD_LIBRARY_PATH="${EXTRACTOR_PATH}" "${EXTRACTOR_PATH}/${EXTRACTOR_BIN}" "${PAT_FILE}" "${UNTAR_PAT_PATH}" - else - # Untar PAT file - tar -xf "${PAT_FILE}" -C "${UNTAR_PAT_PATH}" >"${LOG_FILE}" 2>&1 - fi - # Cleanup PAT Download - rm -f "${PAT_FILE}" - elif [ -f "${DSM_FILE}" ]; then - tar -xf "${DSM_FILE}" -C "${UNTAR_PAT_PATH}" >"${LOG_FILE}" 2>&1 - elif [ ! -f "${UNTAR_PAT_PATH}/zImage" ]; then - dialog --backtitle "$(backtitle)" --title "DSM Download" --aspect 18 \ - --infobox "ERROR: No DSM Image found!" 0 0 - sleep 5 - return 1 - fi - dialog --backtitle "$(backtitle)" --colors --title "Arc Build" \ - --infobox "Image unpack sucessfull..." 3 30 - # Copy DSM Files to Locations if DSM Files not found - cp -f "${UNTAR_PAT_PATH}/grub_cksum.syno" "${PART1_PATH}" - cp -f "${UNTAR_PAT_PATH}/GRUB_VER" "${PART1_PATH}" - cp -f "${UNTAR_PAT_PATH}/grub_cksum.syno" "${PART2_PATH}" - cp -f "${UNTAR_PAT_PATH}/GRUB_VER" "${PART2_PATH}" - cp -f "${UNTAR_PAT_PATH}/zImage" "${ORI_ZIMAGE_FILE}" - cp -f "${UNTAR_PAT_PATH}/rd.gz" "${ORI_RDGZ_FILE}" - rm -rf "${UNTAR_PAT_PATH}" - fi - # Reset Bootcount if User rebuild DSM - if [[ -z "${BOOTCOUNT}" || ${BOOTCOUNT} -gt 0 ]]; then - writeConfigKey "arc.bootcount" "0" "${USER_CONFIG_FILE}" - fi - ( - livepatch - sleep 3 - ) 2>&1 | dialog --backtitle "$(backtitle)" --colors --title "Build Loader" \ - --progressbox "Doing the Magic..." 20 70 - if [[ -f "${ORI_ZIMAGE_FILE}" && -f "${ORI_RDGZ_FILE}" && -f "${MOD_ZIMAGE_FILE}" && -f "${MOD_RDGZ_FILE}" ]]; then - # Build is done - writeConfigKey "arc.builddone" "true" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - boot && exit 0 - fi -} - -############################################################################### -# Calls boot.sh to boot into DSM kernel/ramdisk -function boot() { - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - [ "${BUILDDONE}" = "false" ] && dialog --backtitle "$(backtitle)" --title "Alert" \ - --yesno "Config changed, you need to rebuild the Loader?" 0 0 - if [ $? -eq 0 ]; then - premake - fi - dialog --backtitle "$(backtitle)" --title "Arc Boot" \ - --infobox "Booting DSM...\nPlease stay patient!" 4 25 - sleep 2 - exec reboot -} - -############################################################################### -############################################################################### -# Main loop -arcAutomated - -# Inform user -echo -e "Call \033[1;34marc.sh\033[0m to configure Loader" -echo -echo -e "SSH Access:" -echo -e "IP: \033[1;34m${IPCON}\033[0m" -echo -e "User: \033[1;34mroot\033[0m" -echo -e "Password: \033[1;34marc\033[0m" -echo -echo -e "Web Terminal:" -echo -e "Address: \033[1;34mhttp://${IPCON}:7681\033[0m" \ No newline at end of file diff --git a/files/initrd/opt/arc/boot.sh b/files/initrd/opt/arc/boot.sh index 86de6f22..2c33064f 100755 --- a/files/initrd/opt/arc/boot.sh +++ b/files/initrd/opt/arc/boot.sh @@ -65,6 +65,18 @@ if [[ ! -f "${MODEL_CONFIG_PATH}/${MODEL}.yml" || -z "$(readModelKey "${MODEL}" exit 1 fi +if ! readConfigMap "addons" "${USER_CONFIG_FILE}" | grep -q nvmesystem; then + HASATA=0 + for D in $(lsblk -dpno NAME); do + [ "${D}" = "${LOADER_DISK}" ] && continue + if [ "$(getBus "${D}")" = "sata" -o "$(getBus "${D}")" = "scsi" ]; then + HASATA=1 + break + fi + done + [ ${HASATA} = "0" ] && echo -e "\033[1;31m*** Please insert at least one Sata/SAS/SCSI Disk for System installation, except for the Bootloader Disk. ***\033[0m" +fi + # Read necessary variables VID="$(readConfigKey "vid" "${USER_CONFIG_FILE}")" PID="$(readConfigKey "pid" "${USER_CONFIG_FILE}")" @@ -127,13 +139,7 @@ CMDLINE['console']="ttyS0,115200n8" CMDLINE['consoleblank']="600" CMDLINE['earlyprintk']="" CMDLINE['earlycon']="uart8250,io,0x3f8,115200n8" - -# eMMC Boot -if [ "${EMMCBOOT}" = "false" ]; then - CMDLINE['root']="/dev/md0" -elif [ "${EMMCBOOT}" = "true" ]; then - CMDLINE['root']="/dev/mmcblk0p1" -fi +CMDLINE['root']="/dev/md0" [ ! "${MODEL}" = "SA6400" ] && CMDLINE['elevator']="elevator" CMDLINE['loglevel']="15" diff --git a/files/initrd/opt/arc/include/addons.sh b/files/initrd/opt/arc/include/addons.sh index cf15e5eb..cdd33d0c 100755 --- a/files/initrd/opt/arc/include/addons.sh +++ b/files/initrd/opt/arc/include/addons.sh @@ -10,12 +10,12 @@ function availableAddons() { for D in $(find "${ADDONS_PATH}" -maxdepth 1 -type d 2>/dev/null | sort); do [ ! -f "${D}/manifest.yml" ] && continue ADDON=$(basename ${D}) - checkAddonExist "${ADDON}" "${1}" "${2}" || continue + ACT="$(readConfigKey "${1}" "${D}/manifest.yml")" + [ "${ACT}" = false ] && continue SYSTEM=$(readConfigKey "system" "${D}/manifest.yml") [ "${SYSTEM}" = true ] && continue DESC="$(readConfigKey "description" "${D}/manifest.yml")" BETA="$(readConfigKey "beta" "${D}/manifest.yml")" - ACT="$(readConfigKey "${1}" "${D}/manifest.yml")" [ "${BETA}" = true ] && BETA="(Beta) " || BETA="" [ "${ACT}" = true ] && echo -e "${ADDON}\t${BETA}${DESC}" done diff --git a/files/initrd/opt/arc/include/consts.sh b/files/initrd/opt/arc/include/consts.sh index 8fbb2430..6682697d 100755 --- a/files/initrd/opt/arc/include/consts.sh +++ b/files/initrd/opt/arc/include/consts.sh @@ -6,7 +6,6 @@ ARC_TITLE="Arc ${ARC_VERSION}" PART1_PATH="/mnt/p1" PART2_PATH="/mnt/p2" PART3_PATH="/mnt/p3" -DSMROOT_PATH="/mnt/dsmroot" TMP_PATH="/tmp" UNTAR_PAT_PATH="${TMP_PATH}/DSM" @@ -14,12 +13,7 @@ RAMDISK_PATH="${TMP_PATH}/ramdisk" LOG_FILE="${TMP_PATH}/log.txt" UPLOAD_PATH="${TMP_PATH}/upload" -PRESET_CONFIG_FILE="${PART1_PATH}/preset-config.yml" -if [ -f "${PRESET_CONFIG_FILE}" ]; then - USER_CONFIG_FILE="${PART1_PATH}/preset-config.yml" -else - USER_CONFIG_FILE="${PART1_PATH}/user-config.yml" -fi +USER_CONFIG_FILE="${PART1_PATH}/user-config.yml" GRUB_PATH="${PART1_PATH}/boot/grub" ORI_ZIMAGE_FILE="${PART2_PATH}/zImage" diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index f1f30921..c42e838b 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -221,12 +221,12 @@ function getIP() { # Find and mount the DSM root filesystem # (based on pocopico's TCRP code) function findAndMountDSMRoot() { - [ $(mount | grep -i "${DSMROOT_PATH}" | wc -l) -gt 0 ] && return 0 + [ $(mount | grep -i "${TMP_PATH}/mdX" | wc -l) -gt 0 ] && return 0 dsmrootdisk="$(blkid | grep -i linux_raid_member | grep -E "/dev/.*1:" | head -1 | awk -F ":" '{print $1}')" [ -z "${dsmrootdisk}" ] && return 1 - [ ! -d "${DSMROOT_PATH}" ] && mkdir -p "${DSMROOT_PATH}" - [ $(mount | grep -i "${DSMROOT_PATH}" | wc -l) -eq 0 ] && mount -t ext4 "${dsmrootdisk}" "${DSMROOT_PATH}" - if [ $(mount | grep -i "${DSMROOT_PATH}" | wc -l) -eq 0 ]; then + [ ! -d "${TMP_PATH}/mdX" ] && mkdir -p "${TMP_PATH}/mdX" + [ $(mount | grep -i "${TMP_PATH}/mdX" | wc -l) -eq 0 ] && mount -t ext4 "${dsmrootdisk}" "${TMP_PATH}/mdX" + if [ $(mount | grep -i "${TMP_PATH}/mdX" | wc -l) -eq 0 ]; then echo "Failed to mount" return 1 fi @@ -394,7 +394,7 @@ function livepatch() { # Rebooting # (based on pocopico's TCRP code) function rebootTo() { - MODES="config recovery junior" + MODES="config recovery junior automated update" [ -z "${1}" ] && exit 1 if ! echo "${MODES}" | grep -qw "${1}"; then exit 1; fi # echo "Rebooting to ${1} mode" diff --git a/files/initrd/opt/arc/include/network.sh b/files/initrd/opt/arc/include/network.sh index 0f17e596..792d33dc 100755 --- a/files/initrd/opt/arc/include/network.sh +++ b/files/initrd/opt/arc/include/network.sh @@ -52,6 +52,29 @@ function getnet() { MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")" } +# Get Network Config for Loader +function autogetnet() { + ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) || true + ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" + if [ "${ARCPATCH}" = "true" ]; then + ARCMACNUM=1 + for ETH in ${ETHX}; do + ARCMAC="$(readModelKey "${MODEL}" "arc.mac${ARCMACNUM}")" + [ -n "${ARCMAC}" ] && writeConfigKey "mac.${ETH}" "${ARCMAC}" "${USER_CONFIG_FILE}" + [ -z "${ARCMAC}" ] && break + ARCMACNUM=$((${ARCMACNUM} + 1)) + ARCMAC="" + done + elif [ "${ARCPATCH}" = "false" ]; then + for ETH in ${ETHX}; do + MACS=$(generateMacAddress "${MODEL}" 1) + writeConfigKey "mac.${ETH}" "${MAC}" "${USER_CONFIG_FILE}" + done + fi + writeConfigKey "arc.macsys" "hardware" "${USER_CONFIG_FILE}" + MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")" +} + # Get Amount of NIC ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) || true # Get actual IP diff --git a/files/initrd/opt/arc/include/network_automated.sh b/files/initrd/opt/arc/include/network_automated.sh deleted file mode 100755 index 8aabef70..00000000 --- a/files/initrd/opt/arc/include/network_automated.sh +++ /dev/null @@ -1,30 +0,0 @@ -# Get Network Config for Loader -function getnet() { - ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) || true - ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")" - if [ "${ARCPATCH}" = "true" ]; then - ARCMACNUM=1 - for ETH in ${ETHX}; do - ARCMAC="$(readModelKey "${MODEL}" "arc.mac${ARCMACNUM}")" - [ -n "${ARCMAC}" ] && writeConfigKey "mac.${ETH}" "${ARCMAC}" "${USER_CONFIG_FILE}" - [ -z "${ARCMAC}" ] && break - ARCMACNUM=$((${ARCMACNUM} + 1)) - ARCMAC="" - done - elif [ "${ARCPATCH}" = "false" ]; then - for ETH in ${ETHX}; do - MACS=$(generateMacAddress "${MODEL}" 1) - writeConfigKey "mac.${ETH}" "${MAC}" "${USER_CONFIG_FILE}" - done - fi - writeConfigKey "arc.macsys" "hardware" "${USER_CONFIG_FILE}" - MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")" -} - -# Get Amount of NIC -ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) || true -# Get actual IP -for ETH in ${ETHX}; do - IPCON="$(getIP ${ETH})" - [ -n "${IPCON}" ] && break -done \ No newline at end of file diff --git a/files/initrd/opt/arc/include/storage.sh b/files/initrd/opt/arc/include/storage.sh index d496a7a0..8ebf1eb5 100755 --- a/files/initrd/opt/arc/include/storage.sh +++ b/files/initrd/opt/arc/include/storage.sh @@ -219,6 +219,62 @@ function getmapSelection() { fi } +function autogetmapSelection() { + # Check for Sata Boot + LASTDRIVE=0 + while read -r LINE; do + if [[ "${BUS}" != "usb" && ${LINE} -eq 0 && "${LOADER_DISK}" = "/dev/sda" ]]; then + MAXDISKS="$(readModelKey "${MODEL}" "disks")" + if [ ${MAXDISKS} -lt ${DRIVES} ]; then + MAXDISKS=${DRIVES} + fi + echo -n "${LINE}>${MAXDISKS}:">>"${TMP_PATH}/remap" + elif [ ! ${LINE} = ${LASTDRIVE} ]; then + echo -n "${LINE}>${LASTDRIVE}:">>"${TMP_PATH}/remap" + LASTDRIVE=$((${LASTDRIVE} + 1)) + elif [ ${LINE} = ${LASTDRIVE} ]; then + LASTDRIVE=$((${LINE} + 1)) + fi + done <<<$(cat "${TMP_PATH}/ports") + # Compute PortMap Options + SATAPORTMAPMAX="$(awk '{print $1}' "${TMP_PATH}/drivesmax")" + SATAPORTMAP="$(awk '{print $1}' "${TMP_PATH}/drivescon")" + SATAREMAP="$(awk '{print $1}' "${TMP_PATH}/remap" | sed 's/.$//')" + EXTERNALCONTROLLER="$(readConfigKey "device.externalcontroller" "${USER_CONFIG_FILE}")" + # Show recommended Option to user + if [[ -n "${SATAREMAP}" && "${EXTERNALCONTROLLER}" = "true" && "${MACHINE}" = "NATIVE" ]]; then + writeConfigKey "arc.remap" "maxports" "${USER_CONFIG_FILE}" + elif [[ -n "${SATAREMAP}" && "${EXTERNALCONTROLLER}" = "false" ]]; then + writeConfigKey "arc.remap" "remap" "${USER_CONFIG_FILE}" + else + writeConfigKey "arc.remap" "acports" "${USER_CONFIG_FILE}" + fi + # Check Remap for correct config + REMAP="$(readConfigKey "arc.remap" "${USER_CONFIG_FILE}")" + # Write Map to config and show Map to User + if [ "${REMAP}" = "acports" ]; then + writeConfigKey "cmdline.SataPortMap" "${SATAPORTMAP}" "${USER_CONFIG_FILE}" + writeConfigKey "cmdline.DiskIdxMap" "${DISKIDXMAP}" "${USER_CONFIG_FILE}" + deleteConfigKey "cmdline.sata_remap" "${USER_CONFIG_FILE}" + elif [ "${REMAP}" = "maxports" ]; then + writeConfigKey "cmdline.SataPortMap" "${SATAPORTMAPMAX}" "${USER_CONFIG_FILE}" + writeConfigKey "cmdline.DiskIdxMap" "${DISKIDXMAPMAX}" "${USER_CONFIG_FILE}" + deleteConfigKey "cmdline.sata_remap" "${USER_CONFIG_FILE}" + elif [ "${REMAP}" = "remap" ]; then + writeConfigKey "cmdline.sata_remap" "${SATAREMAP}" "${USER_CONFIG_FILE}" + deleteConfigKey "cmdline.DiskIdxMap" "${USER_CONFIG_FILE}" + deleteConfigKey "cmdline.SataPortMap" "${USER_CONFIG_FILE}" + elif [ "${REMAP}" = "ahci" ]; then + writeConfigKey "cmdline.ahci_remap" "${SATAREMAP}" "${USER_CONFIG_FILE}" + deleteConfigKey "cmdline.DiskIdxMap" "${USER_CONFIG_FILE}" + deleteConfigKey "cmdline.SataPortMap" "${USER_CONFIG_FILE}" + elif [ "${REMAP}" = "user" ]; then + deleteConfigKey "cmdline.SataPortMap" "${USER_CONFIG_FILE}" + deleteConfigKey "cmdline.DiskIdxMap" "${USER_CONFIG_FILE}" + deleteConfigKey "cmdline.sata_remap" "${USER_CONFIG_FILE}" + fi +} + # Check for Controller // 104=RAID // 106=SATA // 107=SAS // 100=SCSI // c03=USB if [ $(lspci -d ::106 | wc -l) -gt 0 ]; then SATACONTROLLER=$(lspci -d ::106 | wc -l) diff --git a/files/initrd/opt/arc/include/storage_automated.sh b/files/initrd/opt/arc/include/storage_automated.sh deleted file mode 100755 index 8404c345..00000000 --- a/files/initrd/opt/arc/include/storage_automated.sh +++ /dev/null @@ -1,198 +0,0 @@ -# Get PortMap for Loader -function getmap() { - # Sata Disks - SATADRIVES=0 - if [ $(lspci -d ::106 | wc -l) -gt 0 ]; then - # Clean old files - [ -f "${TMP_PATH}/drivesmax" ] && rm -f "${TMP_PATH}/drivesmax" - touch "${TMP_PATH}/drivesmax" - [ -f "${TMP_PATH}/drivescon" ] && rm -f "${TMP_PATH}/drivescon" - touch "${TMP_PATH}/drivescon" - [ -f "${TMP_PATH}/ports" ] && rm -f "${TMP_PATH}/ports" - touch "${TMP_PATH}ports" - [ -f "${TMP_PATH}/remap" ] && rm -f "${TMP_PATH}/remap" - touch "${TMP_PATH}/remap" - let DISKIDXMAPIDX=0 - DISKIDXMAP="" - let DISKIDXMAPIDXMAX=0 - DISKIDXMAPMAX="" - for PCI in $(lspci -d ::106 | awk '{print $1}'); do - NUMPORTS=0 - CONPORTS=0 - unset HOSTPORTS - declare -A HOSTPORTS - while read -r LINE; do - ATAPORT="$(echo ${LINE} | grep -o 'ata[0-9]*')" - PORT=$(echo ${ATAPORT} | sed 's/ata//') - HOSTPORTS[${PORT}]=$(echo ${LINE} | grep -o 'host[0-9]*$') - done <<<$(ls -l /sys/class/scsi_host | grep -F "${PCI}") - while read -r PORT; do - ls -l /sys/block | grep -F -q "${PCI}/ata${PORT}" && ATTACH=1 || ATTACH=0 - PCMD=$(cat /sys/class/scsi_host/${HOSTPORTS[${PORT}]}/ahci_port_cmd) - [ ${PCMD} = 0 ] && DUMMY=1 || DUMMY=0 - [ ${ATTACH} = 1 ] && CONPORTS="$((${CONPORTS} + 1))" && echo "$((${PORT} - 1))" >>"${TMP_PATH}/ports" - [ ${DUMMY} = 1 ] # Do nothing for now - NUMPORTS=$((${NUMPORTS} + 1)) - done <<<$(echo ${!HOSTPORTS[@]} | tr ' ' '\n' | sort -n) - [ ${NUMPORTS} -gt 8 ] && NUMPORTS=8 - [ ${CONPORTS} -gt 8 ] && CONPORTS=8 - echo -n "${NUMPORTS}" >>"${TMP_PATH}/drivesmax" - echo -n "${CONPORTS}" >>"${TMP_PATH}/drivescon" - DISKIDXMAP=$DISKIDXMAP$(printf "%02x" $DISKIDXMAPIDX) - let DISKIDXMAPIDX=$DISKIDXMAPIDX+$CONPORTS - DISKIDXMAPMAX=$DISKIDXMAPMAX$(printf "%02x" $DISKIDXMAPIDXMAX) - let DISKIDXMAPIDXMAX=$DISKIDXMAPIDXMAX+$NUMPORTS - SATADRIVES=$((${SATADRIVES} + ${CONPORTS})) - done - fi - # SAS Disks - SASDRIVES=0 - if [ $(lspci -d ::107 | wc -l) -gt 0 ]; then - for PCI in $(lspci -d ::107 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://") - PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l) - SASDRIVES=$((${SASDRIVES} + ${PORTNUM})) - done - fi - # SCSI Disks - SCSIDRIVES=0 - if [ $(lspci -d ::100 | wc -l) -gt 0 ]; then - for PCI in $(lspci -d ::100 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://") - PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l) - SCSIDRIVES=$((${SCSIDRIVES} + ${PORTNUM})) - done - fi - # Raid Disks - RAIDDRIVES=0 - if [ $(lspci -d ::104 | wc -l) -gt 0 ]; then - for PCI in $(lspci -d ::104 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://") - PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l) - RAIDDRIVES=$((${RAIDDRIVES} + ${PORTNUM})) - done - fi - # USB Disks - USBDRIVES=0 - if [[ -d "/sys/class/scsi_host" && $(ls -l /sys/class/scsi_host | grep usb | wc -l) -gt 0 ]]; then - for PCI in $(lspci -d ::c03 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://") - PORT=$(ls -l /sys/class/scsi_host | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/host//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[${PORT}:" | wc -l) - [ ${PORTNUM} -eq 0 ] && continue - USBDRIVES=$((${USBDRIVES} + ${PORTNUM})) - done - fi - # MMC Disks - MMCDRIVES=0 - if [[ -d "/sys/class/mmc_host" && $(ls -l /sys/class/mmc_host | grep mmc_host | wc -l) -gt 0 ]]; then - for PCI in $(lspci -d ::805 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://") - PORTNUM=$(ls -l /sys/block/mmc* | grep "${PCI}" | wc -l) - [ ${PORTNUM} -eq 0 ] && continue - MMCDRIVES=$((${MMCDRIVES} + ${PORTNUM})) - done - fi - # NVMe Disks - NVMEDRIVES=0 - if [ $(lspci -d ::108 | wc -l) -gt 0 ]; then - for PCI in $(lspci -d ::108 | awk '{print $1}'); do - NAME=$(lspci -s "${PCI}" | sed "s/\ .*://") - PORT=$(ls -l /sys/class/nvme | grep "${PCI}" | awk -F'/' '{print $NF}' | sed 's/nvme//' | sort -n) - PORTNUM=$(lsscsi -b | grep -v - | grep "\[N:${PORT}:" | wc -l) - NVMEDRIVES=$((${NVMEDRIVES} + ${PORTNUM})) - done - fi - # Disk Count for MaxDisks - DRIVES=$((${SATADRIVES} + ${SASDRIVES} + ${SCSIDRIVES} + ${RAIDDRIVES} + ${USBDRIVES} + ${MMCDRIVES} + ${NVMEDRIVES})) - HARDDRIVES=$((${SATADRIVES} + ${SASDRIVES} + ${SCSIDRIVES} + ${RAIDDRIVES} + ${NVMEDRIVES})) - writeConfigKey "device.satadrives" "${SATADRIVES}" "${USER_CONFIG_FILE}" - writeConfigKey "device.sasdrives" "${SASDRIVES}" "${USER_CONFIG_FILE}" - writeConfigKey "device.scsidrives" "${SCSIDRIVES}" "${USER_CONFIG_FILE}" - writeConfigKey "device.raiddrives" "${RAIDDRIVES}" "${USER_CONFIG_FILE}" - writeConfigKey "device.usbdrives" "${USBDRIVES}" "${USER_CONFIG_FILE}" - writeConfigKey "device.mmcdrives" "${MMCDRIVES}" "${USER_CONFIG_FILE}" - writeConfigKey "device.nvmedrives" "${NVMEDRIVES}" "${USER_CONFIG_FILE}" - writeConfigKey "device.drives" "${DRIVES}" "${USER_CONFIG_FILE}" - writeConfigKey "device.harddrives" "${HARDDRIVES}" "${USER_CONFIG_FILE}" -} - -function getmapSelection() { - # Check for Sata Boot - LASTDRIVE=0 - while read -r LINE; do - if [[ "${BUS}" != "usb" && ${LINE} -eq 0 && "${LOADER_DISK}" = "/dev/sda" ]]; then - MAXDISKS="$(readModelKey "${MODEL}" "disks")" - if [ ${MAXDISKS} -lt ${DRIVES} ]; then - MAXDISKS=${DRIVES} - fi - echo -n "${LINE}>${MAXDISKS}:">>"${TMP_PATH}/remap" - elif [ ! ${LINE} = ${LASTDRIVE} ]; then - echo -n "${LINE}>${LASTDRIVE}:">>"${TMP_PATH}/remap" - LASTDRIVE=$((${LASTDRIVE} + 1)) - elif [ ${LINE} = ${LASTDRIVE} ]; then - LASTDRIVE=$((${LINE} + 1)) - fi - done <<<$(cat "${TMP_PATH}/ports") - # Compute PortMap Options - SATAPORTMAPMAX="$(awk '{print $1}' "${TMP_PATH}/drivesmax")" - SATAPORTMAP="$(awk '{print $1}' "${TMP_PATH}/drivescon")" - SATAREMAP="$(awk '{print $1}' "${TMP_PATH}/remap" | sed 's/.$//')" - EXTERNALCONTROLLER="$(readConfigKey "device.externalcontroller" "${USER_CONFIG_FILE}")" - # Show recommended Option to user - if [[ -n "${SATAREMAP}" && "${EXTERNALCONTROLLER}" = "true" && "${MACHINE}" = "NATIVE" ]]; then - writeConfigKey "arc.remap" "maxports" "${USER_CONFIG_FILE}" - elif [[ -n "${SATAREMAP}" && "${EXTERNALCONTROLLER}" = "false" ]]; then - writeConfigKey "arc.remap" "remap" "${USER_CONFIG_FILE}" - else - writeConfigKey "arc.remap" "acports" "${USER_CONFIG_FILE}" - fi - # Check Remap for correct config - REMAP="$(readConfigKey "arc.remap" "${USER_CONFIG_FILE}")" - # Write Map to config and show Map to User - if [ "${REMAP}" = "acports" ]; then - writeConfigKey "cmdline.SataPortMap" "${SATAPORTMAP}" "${USER_CONFIG_FILE}" - writeConfigKey "cmdline.DiskIdxMap" "${DISKIDXMAP}" "${USER_CONFIG_FILE}" - deleteConfigKey "cmdline.sata_remap" "${USER_CONFIG_FILE}" - elif [ "${REMAP}" = "maxports" ]; then - writeConfigKey "cmdline.SataPortMap" "${SATAPORTMAPMAX}" "${USER_CONFIG_FILE}" - writeConfigKey "cmdline.DiskIdxMap" "${DISKIDXMAPMAX}" "${USER_CONFIG_FILE}" - deleteConfigKey "cmdline.sata_remap" "${USER_CONFIG_FILE}" - elif [ "${REMAP}" = "remap" ]; then - writeConfigKey "cmdline.sata_remap" "${SATAREMAP}" "${USER_CONFIG_FILE}" - deleteConfigKey "cmdline.DiskIdxMap" "${USER_CONFIG_FILE}" - deleteConfigKey "cmdline.SataPortMap" "${USER_CONFIG_FILE}" - elif [ "${REMAP}" = "ahci" ]; then - writeConfigKey "cmdline.ahci_remap" "${SATAREMAP}" "${USER_CONFIG_FILE}" - deleteConfigKey "cmdline.DiskIdxMap" "${USER_CONFIG_FILE}" - deleteConfigKey "cmdline.SataPortMap" "${USER_CONFIG_FILE}" - elif [ "${REMAP}" = "user" ]; then - deleteConfigKey "cmdline.SataPortMap" "${USER_CONFIG_FILE}" - deleteConfigKey "cmdline.DiskIdxMap" "${USER_CONFIG_FILE}" - deleteConfigKey "cmdline.sata_remap" "${USER_CONFIG_FILE}" - fi -} - -# Check for Controller // 104=RAID // 106=SATA // 107=SAS // 100=SCSI // c03=USB -if [ $(lspci -d ::106 | wc -l) -gt 0 ]; then - SATACONTROLLER=$(lspci -d ::106 | wc -l) - writeConfigKey "device.satacontroller" "${SATACONTROLLER}" "${USER_CONFIG_FILE}" -fi -if [ $(lspci -d ::107 | wc -l) -gt 0 ]; then - SASCONTROLLER=$(lspci -d ::107 | wc -l) - writeConfigKey "device.sascontroller" "${SASCONTROLLER}" "${USER_CONFIG_FILE}" - writeConfigKey "device.externalcontroller" "true" "${USER_CONFIG_FILE}" -fi -if [ $(lspci -d ::100 | wc -l) -gt 0 ]; then - SCSICONTROLLER=$(lspci -d ::100 | wc -l) - writeConfigKey "device.scsicontroller" "${SCSICONTROLLER}" "${USER_CONFIG_FILE}" - writeConfigKey "device.externalcontroller" "true" "${USER_CONFIG_FILE}" -fi -if [ $(lspci -d ::104 | wc -l) -gt 0 ]; then - RAIDCONTROLLER=$(lspci -d ::104 | wc -l) - writeConfigKey "device.raidcontroller" "${RAIDCONTROLLER}" "${USER_CONFIG_FILE}" - writeConfigKey "device.externalcontroller" "true" "${USER_CONFIG_FILE}" -fi \ No newline at end of file diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index 27912f7b..e4085d22 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -65,6 +65,7 @@ initConfigKey "arc.modulescopy" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.hddsort" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.usbmount" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.kernel" "official" "${USER_CONFIG_FILE}" +initConfigKey "arc.custom" "false" "${USER_CONFIG_FILE}" initConfigKey "arc.version" "${ARC_VERSION}" "${USER_CONFIG_FILE}" initConfigKey "device" "{}" "${USER_CONFIG_FILE}" initConfigKey "device.externalcontroller" "false" "${USER_CONFIG_FILE}" @@ -72,12 +73,6 @@ initConfigKey "ip" "{}" "${USER_CONFIG_FILE}" initConfigKey "netmask" "{}" "${USER_CONFIG_FILE}" initConfigKey "mac" "{}" "${USER_CONFIG_FILE}" initConfigKey "static" "{}" "${USER_CONFIG_FILE}" -# KVM Check -if grep -q -E '(vmx|svm)' /proc/cpuinfo; then - initConfigKey "arc.kvm" "true" "${USER_CONFIG_FILE}" -else - initConfigKey "arc.kvm" "false" "${USER_CONFIG_FILE}" -fi # Init Network ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) || true @@ -145,8 +140,10 @@ BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" # Decide if boot automatically if grep -q "force_arc" /proc/cmdline; then echo -e "\033[1;34mLoading Config Mode.\033[0m" -elif grep -q "automated" /proc/cmdline; then +elif grep -q "automated_arc" /proc/cmdline; then echo -e "\033[1;34mLoading Automated Config Mode.\033[0m" +elif grep -q "update_arc" /proc/cmdline; then + echo -e "\033[1;34mLoading Update Mode.\033[0m" elif [ "${BUILDDONE}" = "true" ]; then echo -e "\033[1;34mLoading DSM Mode.\033[0m" boot.sh && exit 0 @@ -224,8 +221,8 @@ if [ ${RAM} -le 3500 ]; then echo -e "\033[1;31mYou have less than 4GB of RAM, if errors occur in loader creation, please increase the amount of RAM.\033[0m\n" echo -e "\033[1;31mUse arc.sh to proceed. Not recommended!\033[0m\n" else - if grep -q "automated" /proc/cmdline; then - automated.sh + if grep -q "update_arc" /proc/cmdline; then + update.sh else arc.sh fi diff --git a/files/initrd/opt/arc/ramdisk-patch.sh b/files/initrd/opt/arc/ramdisk-patch.sh index 0814991e..6e96fd1c 100755 --- a/files/initrd/opt/arc/ramdisk-patch.sh +++ b/files/initrd/opt/arc/ramdisk-patch.sh @@ -36,7 +36,6 @@ KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")" PLATFORM="$(readModelKey "${MODEL}" "platform")" HDDSORT="$(readConfigKey "arc.hddsort" "${USER_CONFIG_FILE}")" USBMOUNT="$(readConfigKey "arc.usbmount" "${USER_CONFIG_FILE}")" -KVMSUPPORT="$(readConfigKey "arc.kvm" "${USER_CONFIG_FILE}")" MODULESCOPY="$(readConfigKey "arc.modulescopy" "${USER_CONFIG_FILE}")" KERNEL="$(readConfigKey "kernel" "${USER_CONFIG_FILE}")" @@ -158,13 +157,13 @@ chmod +x "${RAMDISK_PATH}/addons/addons.sh" # Required addons: "revert" "misc" "eudev" "disks" "localrss" "wol" # This order cannot be changed. -for ADDON in "revert" "misc" "eudev" "disks" "localrss" "notify" "wol"; do +for ADDON in "revert" "misc" "eudev" "disks" "localrss" "notify" "updatenotify" "wol"; do PARAMS="" if [ "${ADDON}" = "disks" ]; then PARAMS='${HDDSORT} ${USBMOUNT}' fi if [ "${ADDON}" = "eudev" ]; then - PARAMS='${MODULESCOPY} ${KVMSUPPORT}' + PARAMS='${MODULESCOPY}' fi installAddon "${ADDON}" "${PLATFORM}" "${KVER}" || exit 1 echo "/addons/${ADDON}.sh \${1} ${PARAMS}" >>"${RAMDISK_PATH}/addons/addons.sh" 2>>"${LOG_FILE}" || exit 1 @@ -194,7 +193,7 @@ else cp -f "${ARC_PATH}/include/modulelist" "${RAMDISK_PATH}/addons/modulelist" fi -# backup current loader configs +# Backup current loader configs BACKUP_PATH="${RAMDISK_PATH}/usr/arc/backup" rm -rf "${BACKUP_PATH}" for F in "${USER_GRUB_CONFIG}" "${USER_CONFIG_FILE}"; do diff --git a/files/initrd/opt/arc/update.sh b/files/initrd/opt/arc/update.sh new file mode 100755 index 00000000..0c57155c --- /dev/null +++ b/files/initrd/opt/arc/update.sh @@ -0,0 +1,255 @@ +#!/usr/bin/env bash + +############################################################################### +# Overlay Init Section +[[ -z "${ARC_PATH}" || ! -d "${ARC_PATH}/include" ]] && ARC_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" + +. ${ARC_PATH}/include/functions.sh + +[ -z "${LOADER_DISK}" ] && die "Loader Disk not found!" + +# Check for Hypervisor +if grep -q "^flags.*hypervisor.*" /proc/cpuinfo; then + # Check for Hypervisor + MACHINE="$(lscpu | grep Hypervisor | awk '{print $3}')" +else + MACHINE="NATIVE" +fi + +# Get Loader Disk Bus +BUS=$(getBus "${LOADER_DISK}") + +# Get DSM Data from Config +MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" +PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" +LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")" +KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")" +LKM="$(readConfigKey "lkm" "${USER_CONFIG_FILE}")" +if [ -n "${MODEL}" ]; then + PLATFORM="$(readModelKey "${MODEL}" "platform")" + DT="$(readModelKey "${MODEL}" "dt")" +fi + +# Get Arc Data from Config +CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")" +BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" +OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")" +CUSTOM="${readConfigKey "arc.custom" "${USER_CONFIG_FILE}"}" + +############################################################################### +# Mounts backtitle dynamically +function backtitle() { + if [ ! -n "${MODEL}" ]; then + MODEL="(Model)" + fi + if [ ! -n "${PRODUCTVER}" ]; then + PRODUCTVER="(Version)" + fi + if [ ! -n "${IPCON}" ]; then + IPCON="(IP)" + fi + BACKTITLE="${ARC_TITLE} | " + BACKTITLE+="${MODEL} | " + BACKTITLE+="${PRODUCTVER} | " + BACKTITLE+="${IPCON} | " + BACKTITLE+="Patch: ${ARCPATCH} | " + BACKTITLE+="Config: ${CONFDONE} | " + BACKTITLE+="Build: ${BUILDDONE} | " + BACKTITLE+="${MACHINE}(${BUS})" + echo "${BACKTITLE}" +} + +############################################################################### +# Auto Update Loader +function arcUpdate() { + # Update Loader + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --infobox "Checking latest version..." 0 0 + ACTUALVERSION="${ARC_VERSION}" + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [[ $? -ne 0 || -z "${TAG}" ]]; then + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --infobox "Error checking new Version!" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --infobox "Downloading ${TAG}" 0 0 + # Download update file + STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc/releases/download/${TAG}/update.zip" -o "${TMP_PATH}/update.zip") + if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --infobox "Error downloading Updatefile!" 0 0 + return 1 + fi + unzip -oq "${TMP_PATH}/update.zip" -d "${TMP_PATH}" + rm -f "${TMP_PATH}/update.zip" + if [ $? -ne 0 ]; then + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --infobox "Error extracting Updatefile!" 0 0 + return 1 + fi + # Process complete update + cp -f "${TMP_PATH}/grub.cfg" "${GRUB_PATH}/grub.cfg" + cp -f "${TMP_PATH}/bzImage-arc" "${ARC_BZIMAGE_FILE}" + cp -f "${TMP_PATH}/initrd-arc" "${ARC_RAMDISK_FILE}" + rm -f "${TMP_PATH}/update.zip" + # Update Addons + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-addons/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [[ $? -ne 0 || -z "${TAG}" ]]; then + dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ + --infobox "Error checking new Version!" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ + --infobox "Downloading ${TAG}" 0 0 + STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons.zip" -o "${TMP_PATH}/addons.zip") + if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then + dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ + --infobox "Error downloading Updatefile!" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ + --infobox "Extracting" 0 0 + rm -rf "${ADDONS_PATH}" + mkdir -p "${ADDONS_PATH}" + unzip -oq "${TMP_PATH}/addons.zip" -d "${ADDONS_PATH}" >/dev/null 2>&1 + dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ + --infobox "Installing new Addons" 0 0 + for PKG in $(ls ${ADDONS_PATH}/*.addon); do + ADDON=$(basename ${PKG} | sed 's|.addon||') + rm -rf "${ADDONS_PATH}/${ADDON:?}" + mkdir -p "${ADDONS_PATH}/${ADDON}" + tar -xaf "${PKG}" -C "${ADDONS_PATH}/${ADDON}" >/dev/null 2>&1 + rm -f "${ADDONS_PATH}/${ADDON}.addon" + done + rm -f "${TMP_PATH}/addons.zip" + # Update Patches + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-patches/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [[ $? -ne 0 || -z "${TAG}" ]]; then + dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ + --infobox "Error checking new Version!" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ + --infobox "Downloading ${TAG}" 0 0 + STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches.zip" -o "${TMP_PATH}/patches.zip") + if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then + dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ + --infobox "Error downloading Updatefile!" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ + --infobox "Extracting" 0 0 + rm -rf "${PATCH_PATH}" + mkdir -p "${PATCH_PATH}" + unzip -oq "${TMP_PATH}/patches.zip" -d "${PATCH_PATH}" >/dev/null 2>&1 + rm -f "${TMP_PATH}/patches.zip" + # Update Modules + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-modules/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [[ $? -ne 0 || -z "${TAG}" ]]; then + dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ + --infobox "Error checking new Version!" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ + --infobox "Downloading ${TAG}" 0 0 + STATUS=$(curl -k -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules.zip" -o "${TMP_PATH}/modules.zip") + if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then + dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ + --infobox "Error downloading Updatefile!" 0 0 + return 1 + fi + MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")" + PRODUCTVER="$(readConfigKey "productver" "${USER_CONFIG_FILE}")" + if [[ -n "${MODEL}" && -n "${PRODUCTVER}" ]]; then + PLATFORM="$(readModelKey "${MODEL}" "platform")" + KVER="$(readModelKey "${MODEL}" "productvers.[${PRODUCTVER}].kver")" + if [ "${PLATFORM}" = "epyc7002" ]; then + KVER="${PRODUCTVER}-${KVER}" + fi + fi + rm -rf "${MODULES_PATH}" + mkdir -p "${MODULES_PATH}" + unzip -oq "${TMP_PATH}/modules.zip" -d "${MODULES_PATH}" >/dev/null 2>&1 + # Rebuild modules if model/build is selected + if [[ -n "${PLATFORM}" && -n "${KVER}" ]]; then + writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}" + while read -r ID DESC; do + writeConfigKey "modules.${ID}" "" "${USER_CONFIG_FILE}" + done <<<$(getAllModules "${PLATFORM}" "${KVER}") + fi + rm -f "${TMP_PATH}/modules.zip" + # Update Configs + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/arc-configs/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [[ $? -ne 0 || -z "${TAG}" ]]; then + dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ + --infobox "Error checking new Version!" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ + --infobox "Downloading ${TAG}" 0 0 + STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs.zip" -o "${TMP_PATH}/configs.zip") + if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then + dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ + --infobox "Error downloading Updatefile!" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ + --infobox "Extracting" 0 0 + rm -rf "${MODEL_CONFIG_PATH}" + mkdir -p "${MODEL_CONFIG_PATH}" + unzip -oq "${TMP_PATH}/configs.zip" -d "${MODEL_CONFIG_PATH}" >/dev/null 2>&1 + rm -f "${TMP_PATH}/configs.zip" + # Update LKMs + TAG="$(curl --insecure -m 5 -s https://api.github.com/repos/AuxXxilium/redpill-lkm/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')" + if [[ $? -ne 0 || -z "${TAG}" ]]; then + dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ + --infobox "Error checking new Version!" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ + --infobox "Downloading ${TAG}" 0 0 + STATUS=$(curl --insecure -s -w "%{http_code}" -L "https://github.com/AuxXxilium/redpill-lkm/releases/download/${TAG}/rp-lkms.zip" -o "${TMP_PATH}/rp-lkms.zip") + if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then + dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ + --infobox "Error downloading Updatefile" 0 0 + return 1 + fi + dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ + --infobox "Extracting" 0 0 + rm -rf "${LKM_PATH}" + mkdir -p "${LKM_PATH}" + unzip -oq "${TMP_PATH}/rp-lkms.zip" -d "${LKM_PATH}" >/dev/null 2>&1 + rm -f "${TMP_PATH}/rp-lkms.zip" + # Ask for Boot + dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + --infobox "Update successfull!" 0 0 + boot +} + +############################################################################### +# Calls boot.sh to boot into DSM kernel/ramdisk +function boot() { + if [ "${CUSTOM}" = "true" ]; then + dialog --backtitle "$(backtitle)" --title "Arc Boot" \ + --infobox "Rebooting Automated Mode...\nPlease stay patient!" 4 25 + sleep 2 + rebootTo automated + else + dialog --backtitle "$(backtitle)" --title "Arc Boot" \ + --infobox "Rebooting Config Mode...\nPlease stay patient!" 4 25 + sleep 2 + rebootTo config + fi +} + +############################################################################### +############################################################################### +# Main loop +if [ "${OFFLINE}" = "false" ]; then + arcUpdate +else + dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ + --infobox "Offline Mode enabled.\nCan't Update Loader!" 0 0 + sleep 5 +fi \ No newline at end of file diff --git a/files/p1/boot/grub/grub.cfg b/files/p1/boot/grub/grub.cfg index 8fd1f103..6bcb3af9 100644 --- a/files/p1/boot/grub/grub.cfg +++ b/files/p1/boot/grub/grub.cfg @@ -96,7 +96,7 @@ if [ -s /automated ]; then menuentry 'Arc Automated Config Mode' --id automated { set_gfxpayload echo "Loading Arc Kernel..." - linux /bzImage-arc ${ARC_CMDLINE} automated + linux /bzImage-arc ${ARC_CMDLINE} automated_arc echo "Loading Arc Initramfs..." initrd /initrd-arc echo "Booting..." @@ -112,6 +112,15 @@ menuentry 'Arc Config Mode' --id config { echo "Booting..." } +menuentry 'Arc Update Mode' --id update { + set_gfxpayload + echo "Loading Arc Kernel..." + linux /bzImage-arc ${ARC_CMDLINE} update_arc + echo "Loading Arc Initramfs..." + initrd /initrd-arc + echo "Booting..." +} + if [ -s /zImage-dsm -a -s /initrd-dsm ]; then menuentry 'DSM Recovery Mode' --id recovery { set_gfxpayload diff --git a/scripts/vm.sh b/scripts/vm.sh new file mode 100755 index 00000000..6b06887a --- /dev/null +++ b/scripts/vm.sh @@ -0,0 +1,211 @@ + +filename=$(basename "${1}") + +OVFNAME=${filename%.*} +BLDISKNAME="${OVFNAME}-disk1.vmdk" +SDDISKNAME="${OVFNAME}-disk2.vmdk" + +# Convert raw image to VMDK +qemu-img convert -O vmdk -o 'adapter_type=lsilogic,subformat=streamOptimized,compat6' "${1}" "${BLDISKNAME}" +#qemu-img create -f vmdk "${SDDISKNAME}" "32G" + +BLSIZE=$(du -b "${BLDISKNAME}" | cut -f 1) +SDSIZE=$(du -b "${SDDISKNAME}" | cut -f 1) +BLVIRTUALSIZE=$(qemu-img info "${BLDISKNAME}" --output json | jq -r '."virtual-size"') +SDVIRTUALSIZE=$(qemu-img info "${SDDISKNAME}" --output json | jq -r '."virtual-size"') + +# Create VM configuration +cat << _EOF_ > "${OVFNAME}.ovf" + + + + + + + + Virtual disk information + + + + + The list of logical networks + + The bridged network + + + + A virtual machine + ${OVFNAME} + + The kind of installed guest operating system + + + Virtual hardware requirements + + Virtual Hardware Family + 0 + ${OVFNAME} + vmx-21 + + + hertz * 10^6 + Number of Virtual CPUs + 2 virtual CPU(s) + 1 + 3 + 2 + 2 + + + byte * 2^20 + Memory Size + 4096MB of memory + 2 + 4 + 4096 + 1 + + + 0 + SATA Controller + sataController0 + 3 + vmware.sata.ahci + 20 + 1 + + + 0 + USB Controller (XHCI) + usb3 + 4 + vmware.usb.xhci + 23 + 1 + + + 0 + USB Controller (EHCI) + usb + 5 + vmware.usb.ehci + 23 + + 1 + + + true + serial0 + 6 + 21 + + + 1 + + + 1 + true + bridged + VmxNet3 ethernet adapter on "bridged" + ethernet0 + 7 + VmxNet3 + 10 + + 1 + + + false + sound + 8 + vmware.soundcard.ensoniq1371 + 1 + 1 + + + false + video + 9 + 24 + + 1 + + + false + vmci + 10 + vmware.vmci + 1 + 1 + + + 0 + disk0 + ovf:/disk/vmdisk1 + 11 + 3 + 17 + 1 + + + 1 + disk1 + ovf:/disk/vmdisk2 + 12 + 3 + 17 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A human-readable annotation + Arc Loader + + + +_EOF_ + +# Create manifest file for automatic integrity check +cat << _EOF_ > "${OVFNAME}.mf" +SHA256(${OVFNAME}.ovf)= $(sha256sum "${OVFNAME}.ovf" | mawk '{print $1}') +SHA256(${BLDISKNAME})= $(sha256sum "${BLDISKNAME}" | mawk '{print $1}') +SHA256(${SDDISKNAME})= $(sha256sum "${SDDISKNAME}" | mawk '{print $1}') +_EOF_ + +# Pack everything as OVA appliance for ESXi import +rm -f "${OVFNAME}.ova" +tar -cf "${OVFNAME}.ova" ${OVFNAME}.ovf ${BLDISKNAME} ${SDDISKNAME} ${OVFNAME}.mf +rm -f ${OVFNAME}.ovf ${BLDISKNAME} ${SDDISKNAME} ${OVFNAME}.mf +#gzip "${OVFNAME}.ova" +