diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index de6255e..ee8c5ba 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -22,7 +22,7 @@ jobs: - name: Check Issues run: | - if echo "${{ github.event.issue.body }}" | grep -q "Screenshots"; then + if echo "${{ github.event.issue.body }}" | grep -q "Hardware"; then echo "FALG=true" >> $GITHUB_ENV else echo "FALG=false" >> $GITHUB_ENV @@ -38,9 +38,14 @@ jobs: body: | **Describe the Bug** A clear and concise description of what the bug is. - - **Screenshots** - Screenshot the Systeminfo (Arc - Sysinfo) or use new "Full Sysinfo - Upload" Function provide the Code!!! <- IMPORTANT - + **Hardware** Add your Hardware Informations here. CPU / Board / Networkcontroller / Storagecontroller / ... + + - name: Close Issues + if: env.FALG == 'false' + uses: actions-cool/issues-helper@v3 + with: + actions: 'close-issue' + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} \ No newline at end of file diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 9fac3cc..2c2c84f 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -60,7 +60,7 @@ function addonSelection() { --checklist "Select Loader Addons to include.\nPlease read Wiki before choosing anything.\nSelect with SPACE, Confirm with ENTER!" 0 0 0 \ --file "${TMP_PATH}/opts" 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 - resp="$(<"${TMP_PATH}/resp")" + resp=$(cat ${TMP_PATH}/resp) unset ADDONS declare -A ADDONS writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" @@ -101,7 +101,7 @@ function modulesMenu() { 6 "Add external module" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && break - case "$(<"${TMP_PATH}/resp")" in + case "$(cat ${TMP_PATH}/resp)" in 1) ITEMS="" for KEY in ${!USERMODULES[@]}; do @@ -159,8 +159,8 @@ function modulesMenu() { dialog --backtitle "$(backtitle)" --title "Modules" --aspect 18 \ --checklist "Select Modules to include" 0 0 0 \ --file "${TMP_PATH}/opts" 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && continue - resp="$(<"${TMP_PATH}/resp")" + [ $? -ne 0 ] && return 1 + resp=$(cat ${TMP_PATH}/resp) dialog --backtitle "$(backtitle)" --title "Modules" \ --infobox "Writing to user config" 20 5 unset USERMODULES @@ -182,18 +182,18 @@ function modulesMenu() { TEXT+="Do you want to continue?" dialog --backtitle "$(backtitle)" --title "Add external Module" \ --yesno "${TEXT}" 0 0 - [ $? -ne 0 ] && continue + [ $? -ne 0 ] && return 1 dialog --backtitle "$(backtitle)" --aspect 18 --colors --inputbox "Please enter the complete URL to download.\n" 0 0 \ 2>"${TMP_PATH}/resp" - URL="$(<"${TMP_PATH}/resp")" - [ -z "${URL}" ] && continue + URL=$(cat "${TMP_PATH}/resp") + [ -z "${URL}" ] && return 1 clear echo "Downloading ${URL}" STATUS=$(curl -kLJO -w "%{http_code}" "${URL}" --progress-bar) if [[ $? -ne 0 || ${STATUS} -ne 200 ]]; then dialog --backtitle "$(backtitle)" --title "Add external Module" --aspect 18 \ --msgbox "ERROR: Check internet, URL or cache disk space" 0 0 - continue + return 1 fi KONAME=$(basename "$URL") if [[ -n "${KONAME}" && "${KONAME##*.}" = "ko" ]]; then @@ -234,7 +234,7 @@ function cmdlineMenu() { dialog --backtitle "$(backtitle)" --menu "Choose an Option" 0 0 0 \ --file "${TMP_PATH}/menu" 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 - case "$(<"${TMP_PATH}/resp")" in + case "$(cat ${TMP_PATH}/resp)" in 1) MSG="" MSG+="Commonly used Parameter:\n" @@ -285,9 +285,9 @@ function cmdlineMenu() { dialog --backtitle "$(backtitle)" \ --checklist "Select cmdline to remove" 0 0 0 ${ITEMS} \ 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && continue - resp="$(<"${TMP_PATH}/resp")" - [ -z "${resp}" ] && continue + [ $? -ne 0 ] && return 1 + resp=$(cat ${TMP_PATH}/resp) + [ -z "${resp}" ] && return 1 for I in ${resp}; do unset 'CMDLINE[${I}]' deleteConfigKey "cmdline.\"${I}\"" "${USER_CONFIG_FILE}" @@ -301,7 +301,7 @@ function cmdlineMenu() { 1 "Install" \ 2 "Uninnstall" \ 2>"${TMP_PATH}/resp" - resp="$(<"${TMP_PATH}/resp")" + resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 if [ ${resp} -eq 1 ]; then writeConfigKey "cmdline.nmi_watchdog" "0" "${USER_CONFIG_FILE}" @@ -323,7 +323,7 @@ function cmdlineMenu() { 1 "Install" \ 2 "Uninnstall" \ 2>"${TMP_PATH}/resp" - resp="$(<"${TMP_PATH}/resp")" + resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 if [ ${resp} -eq 1 ]; then writeConfigKey "cmdline.disable_mtrr_trim" "0" "${USER_CONFIG_FILE}" @@ -345,7 +345,7 @@ function cmdlineMenu() { 1 "Install" \ 2 "Uninnstall" \ 2>"${TMP_PATH}/resp" - resp="$(<"${TMP_PATH}/resp")" + resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 if [ ${resp} -eq 1 ]; then writeConfigKey "cmdline.pci" "routeirq" "${USER_CONFIG_FILE}" @@ -365,7 +365,7 @@ function cmdlineMenu() { 1 "Install" \ 2 "Uninnstall" \ 2>"${TMP_PATH}/resp" - resp="$(<"${TMP_PATH}/resp")" + resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 if [ ${resp} -eq 1 ]; then writeConfigKey "cmdline.intel_idle.max_cstate" "1" "${USER_CONFIG_FILE}" @@ -403,9 +403,9 @@ function cmdlineMenu() { dialog --backtitle "$(backtitle)" --colors --title "Kernelpanic" \ --default-item "${KERNELPANIC}" --menu "Choose a time(seconds)" 0 0 0 --file "${TMP_PATH}/opts" \ 2>${TMP_PATH}/resp - [ $? -ne 0 ] && return - resp=$(cat ${TMP_PATH}/resp 2>/dev/null) - [ -z "${resp}" ] && return + [ $? -ne 0 ] && return 1 + resp=$(cat ${TMP_PATH}/resp) + [ -z "${resp}" ] && return 1 KERNELPANIC=${resp} writeConfigKey "arc.kernelpanic" "${KERNELPANIC}" "${USER_CONFIG_FILE}" ;; @@ -434,19 +434,19 @@ function synoinfoMenu() { dialog --backtitle "$(backtitle)" --menu "Choose an Option" 0 0 0 \ --file "${TMP_PATH}/menu" 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 - case "$(<"${TMP_PATH}/resp")" in + case "$(cat ${TMP_PATH}/resp)" in 1) dialog --backtitle "$(backtitle)" --title "Synoinfo entries" \ --inputbox "Type a name of synoinfo entry" 0 0 \ 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && continue - NAME="$(<"${TMP_PATH}/resp")" - [ -z "${NAME//\"/}" ] && continue + [ $? -ne 0 ] && return 1 + NAME=$(cat "${TMP_PATH}/resp") + [ -z "${NAME//\"/}" ] && return 1 dialog --backtitle "$(backtitle)" --title "Synoinfo entries" \ --inputbox "Type a value of '${NAME}' entry" 0 0 "${SYNOINFO[${NAME}]}" \ 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && continue - VALUE="$(<"${TMP_PATH}/resp")" + [ $? -ne 0 ] && return 1 + VALUE=$(cat "${TMP_PATH}/resp") SYNOINFO[${NAME}]="${VALUE}" writeConfigKey "synoinfo.\"${NAME//\"/}\"" "${VALUE}" "${USER_CONFIG_FILE}" writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" @@ -464,9 +464,9 @@ function synoinfoMenu() { dialog --backtitle "$(backtitle)" \ --checklist "Select synoinfo entry to remove" 0 0 0 ${ITEMS} \ 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && continue - resp="$(<"${TMP_PATH}/resp")" - [ -z "${resp}" ] && continue + [ $? -ne 0 ] && return 1 + resp=$(cat ${TMP_PATH}/resp) + [ -z "${resp}" ] && return 1 for I in ${resp}; do unset 'SYNOINFO[${I}]' deleteConfigKey "synoinfo.\"${I}\"" "${USER_CONFIG_FILE}" @@ -509,7 +509,7 @@ function synoinfoMenu() { 2>"${TMP_PATH}/resp" RET=$? [ ${RET} -ne 0 ] && break 2 - CPUTEMP="$(<"${TMP_PATH}/resp")" + CPUTEMP=$(cat "${TMP_PATH}/resp") if [ "${PLATFORM}" = "geminilake" ]; then sed -i 's|90|'"${CPUTEMP}"'|g' "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml" elif [[ "${PLATFORM}" = "r1000" || "${PLATFORM}" = "v1000" || "${PLATFORM}" = "epyc7002" ]]; then @@ -520,7 +520,7 @@ function synoinfoMenu() { 2>"${TMP_PATH}/resp" RET=$? [ ${RET} -ne 0 ] && break 2 - DISKTEMP="$(<"${TMP_PATH}/resp")" + DISKTEMP=$(cat "${TMP_PATH}/resp") if [ "${PLATFORM}" = "geminilake" ]; then sed -i 's|61|'"${DISKTEMP}"'|g' "/mnt/dsmroot/usr/syno/etc.defaults/scemd.xml" elif [[ "${PLATFORM}" = "r1000" || "${PLATFORM}" = "v1000" || "${PLATFORM}" = "epyc7002" ]]; then @@ -531,7 +531,7 @@ function synoinfoMenu() { 2>"${TMP_PATH}/resp" RET=$? [ ${RET} -ne 0 ] && break 2 - M2TEMP="$(<"${TMP_PATH}/resp")" + M2TEMP=$(cat "${TMP_PATH}/resp") if [ "${PLATFORM}" = "geminilake" ]; then sed -i 's|70|'"${M2TEMP}"'|g' "${DSMROOT_PATH}/usr/syno/etc.defaults/scemd.xml" elif [[ "${PLATFORM}" = "r1000" || "${PLATFORM}" = "v1000" || "${PLATFORM}" = "epyc7002" ]]; then @@ -564,7 +564,7 @@ function keymapMenu() { "dvorak" "fgGIod" "neo" "olpc" "qwerty" "qwertz" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 - LAYOUT="$(<"${TMP_PATH}/resp")" + LAYOUT=$(cat "${TMP_PATH}/resp") OPTIONS="" while read -r KM; do OPTIONS+="${KM::-7} " @@ -572,9 +572,9 @@ function keymapMenu() { dialog --backtitle "$(backtitle)" --no-items --default-item "${KEYMAP}" \ --menu "Choice a keymap" 0 0 0 ${OPTIONS} \ 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && continue - resp="$(<"${TMP_PATH}/resp")" - [ -z "${resp}" ] && continue + [ $? -ne 0 ] && return 1 + resp=$(cat ${TMP_PATH}/resp) + [ -z "${resp}" ] && return 1 KEYMAP=${resp} writeConfigKey "layout" "${LAYOUT}" "${USER_CONFIG_FILE}" writeConfigKey "keymap" "${KEYMAP}" "${USER_CONFIG_FILE}" @@ -592,14 +592,14 @@ function storagepanelMenu() { dialog --backtitle "$(backtitle)" --title "StoragePanel" \ --default-item "24_Bay" --no-items --menu "Choose a Disk Panel" 0 0 0 ${ITEMS} \ 2>"${TMP_PATH}/resp" - resp="$(cat ${TMP_PATH}/resp 2>/dev/null)" + resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 STORAGE=${resp} ITEMS="$(echo -e "1X2 \n1X4 \n1X8 \n")" dialog --backtitle "$(backtitle)" --title "StoragePanel" \ --default-item "1X8" --no-items --menu "Choose a M.2 Panel" 0 0 0 ${ITEMS} \ 2>"${TMP_PATH}/resp" - resp="$(cat ${TMP_PATH}/resp 2>/dev/null)" + resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 M2PANEL=${resp} STORAGEPANEL="RACK_${STORAGE} ${M2PANEL}" @@ -624,7 +624,7 @@ function backupMenu() { 5 "Restore Encryption Key" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 - case "$(<"${TMP_PATH}/resp")" in + case "$(cat ${TMP_PATH}/resp)" in 1) dialog --backtitle "$(backtitle)" --title "Backup Config with Code" \ --infobox "Write down your Code for Restore!" 0 0 @@ -642,7 +642,7 @@ function backupMenu() { 2>"${TMP_PATH}/resp" RET=$? [ ${RET} -ne 0 ] && break 2 - GENHASH="$(<"${TMP_PATH}/resp")" + GENHASH=$(cat "${TMP_PATH}/resp") [ ${#GENHASH} -eq 9 ] && break dialog --backtitle "$(backtitle)" --title "Restore with Code" --msgbox "Invalid Code" 0 0 done @@ -777,7 +777,7 @@ function backupMenu() { 2 "Restore Encryption Key" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 - case "$(<"${TMP_PATH}/resp")" in + case "$(cat ${TMP_PATH}/resp)" in 1) dialog --backtitle "$(backtitle)" --title "Try to recover DSM" --aspect 18 \ --infobox "Trying to recover a DSM installed system" 0 0 @@ -872,7 +872,7 @@ function updateMenu() { 6 "Update LKMs" \ 2>"${TMP_PATH}/resp" [ $? -ne 0 ] && return 1 - case "$(<"${TMP_PATH}/resp")" in + case "$(cat ${TMP_PATH}/resp)" in 1) dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ --infobox "Checking latest version..." 0 0 @@ -883,7 +883,7 @@ function updateMenu() { 1 "Latest" \ 2 "Select Version" \ 2>"${TMP_PATH}/opts" - opts="$(<"${TMP_PATH}/opts")" + 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)}')" @@ -896,15 +896,15 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Upgrade Loader" \ --inputbox "Type the Version!" 0 0 \ 2>"${TMP_PATH}/input" - TAG="$(<"${TMP_PATH}/input")" - [ -z "${TAG}" ] && continue + TAG=$(cat "${TMP_PATH}/input") + [ -z "${TAG}" ] && return 1 fi dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ --infobox "Downloading ${TAG}" 0 0 if [ "${ACTUALVERSION}" = "${TAG}" ]; then dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ --yesno "No new version. Actual version is ${ACTUALVERSION}\nForce update?" 0 0 - [ $? -ne 0 ] && continue + [ $? -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") @@ -937,7 +937,7 @@ function updateMenu() { rm -f "${TMP_PATH}/arc.img" dialog --backtitle "$(backtitle)" --title "Upgrade Loader" --aspect 18 \ --yesno "Arc Upgrade successful. New Version: ${TAG}\nReboot?" 0 0 - [ $? -ne 0 ] && continue + [ $? -ne 0 ] && return 1 exec reboot exit 0 ;; @@ -949,7 +949,7 @@ function updateMenu() { 2 "Select Version" \ 2>"${TMP_PATH}/opts" [ $? -ne 0 ] && continue - opts="$(<"${TMP_PATH}/opts")" + 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)}')" @@ -962,8 +962,8 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update Addons" \ --inputbox "Type the Version!" 0 0 \ 2>"${TMP_PATH}/input" - TAG="$(<"${TMP_PATH}/input")" - [ -z "${TAG}" ] && continue + TAG=$(cat "${TMP_PATH}/input") + [ -z "${TAG}" ] && return 1 fi dialog --backtitle "$(backtitle)" --title "Update Addons" --aspect 18 \ --infobox "Downloading ${TAG}" 0 0 @@ -1000,7 +1000,7 @@ function updateMenu() { 1 "Latest" \ 2 "Select Version" \ 2>"${TMP_PATH}/opts" - opts="$(<"${TMP_PATH}/opts")" + 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)}')" @@ -1013,8 +1013,8 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update Patches" \ --inputbox "Type the Version!" 0 0 \ 2>"${TMP_PATH}/input" - TAG="$(<"${TMP_PATH}/input")" - [ -z "${TAG}" ] && continue + TAG=$(cat "${TMP_PATH}/input") + [ -z "${TAG}" ] && return 1 fi dialog --backtitle "$(backtitle)" --title "Update Patches" --aspect 18 \ --infobox "Downloading ${TAG}" 0 0 @@ -1042,7 +1042,7 @@ function updateMenu() { 1 "Latest" \ 2 "Select Version" \ 2>"${TMP_PATH}/opts" - opts="$(<"${TMP_PATH}/opts")" + 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)}')" @@ -1055,8 +1055,8 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update Modules" \ --inputbox "Type the Version!" 0 0 \ 2>"${TMP_PATH}/input" - TAG="$(<"${TMP_PATH}/input")" - [ -z "${TAG}" ] && continue + TAG=$(cat "${TMP_PATH}/input") + [ -z "${TAG}" ] && return 1 fi dialog --backtitle "$(backtitle)" --title "Update Modules" --aspect 18 \ --infobox "Downloading ${TAG}" 0 0 @@ -1098,7 +1098,7 @@ function updateMenu() { 1 "Latest" \ 2 "Select Version" \ 2>"${TMP_PATH}/opts" - opts="$(<"${TMP_PATH}/opts")" + 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)}')" @@ -1111,8 +1111,8 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update Configs" \ --inputbox "Type the Version!" 0 0 \ 2>"${TMP_PATH}/input" - TAG="$(<"${TMP_PATH}/input")" - [ -z "${TAG}" ] && continue + TAG=$(cat "${TMP_PATH}/input") + [ -z "${TAG}" ] && return 1 fi dialog --backtitle "$(backtitle)" --title "Update Configs" --aspect 18 \ --infobox "Downloading ${TAG}" 0 0 @@ -1140,7 +1140,7 @@ function updateMenu() { 1 "Latest" \ 2 "Select Version" \ 2>"${TMP_PATH}/opts" - opts="$(<"${TMP_PATH}/opts")" + 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)}')" @@ -1153,8 +1153,8 @@ function updateMenu() { dialog --backtitle "$(backtitle)" --title "Update LKMs" \ --inputbox "Type the Version!" 0 0 \ 2>"${TMP_PATH}/input" - TAG="$(<"${TMP_PATH}/input")" - [ -z "${TAG}" ] && continue + TAG=$(cat "${TMP_PATH}/input") + [ -z "${TAG}" ] && return 1 fi dialog --backtitle "$(backtitle)" --title "Update LKMs" --aspect 18 \ --infobox "Downloading ${TAG}" 0 0 @@ -1773,27 +1773,27 @@ function staticIPMenu() { TEXT+="Do you want to change Config?" dialog --backtitle "$(backtitle)" --title "DHCP/StaticIP" \ --yesno "${TEXT}" 0 0 - [ $? -ne 0 ] && continue + [ $? -ne 0 ] && return 1 dialog --clear --backtitle "$(backtitle)" --title "DHCP/StaticIP" \ --menu "DHCP or STATIC?" 0 0 0 \ 1 "DHCP" \ 2 "STATIC" \ 2>"${TMP_PATH}/opts" - opts="$(<"${TMP_PATH}/opts")" - [ -z "${opts}" ] && continue + opts=$(cat ${TMP_PATH}/opts) + [ -z "${opts}" ] && return 1 if [ ${opts} -eq 1 ]; then writeConfigKey "static.${ETH}" "false" "${USER_CONFIG_FILE}" elif [ ${opts} -eq 2 ]; then dialog --backtitle "$(backtitle)" --title "DHCP/StaticIP" \ --inputbox "Type a Static IP\nLike: 192.168.0.1" 0 0 "${IPADDR}" \ 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && continue - IPADDR="$(<"${TMP_PATH}/resp")" + [ $? -ne 0 ] && return 1 + IPADDR=$(cat "${TMP_PATH}/resp") dialog --backtitle "$(backtitle)" --title "DHCP/StaticIP" \ --inputbox "Type a Netmask\nLike: 24" 0 0 "${NETMASK}" \ 2>"${TMP_PATH}/resp" - [ $? -ne 0 ] && continue - NETMASK="$(<"${TMP_PATH}/resp")" + [ $? -ne 0 ] && return 1 + NETMASK=$(cat "${TMP_PATH}/resp") writeConfigKey "ip.${ETH}" "${IPADDR}" "${USER_CONFIG_FILE}" writeConfigKey "netmask.${ETH}" "${NETMASK}" "${USER_CONFIG_FILE}" writeConfigKey "static.${ETH}" "true" "${USER_CONFIG_FILE}" @@ -1857,20 +1857,20 @@ function resetPassword() { 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 + return 1 fi dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ --no-items --menu "Choose a User" 0 0 0 --file "${TMP_PATH}/menu" \ 2>${TMP_PATH}/resp - [ $? -ne 0 ] && return + [ $? -ne 0 ] && return 1 USER="$(cat "${TMP_PATH}/resp" | awk '{print $1}')" - [ -z "${USER}" ] && return + [ -z "${USER}" ] && return 1 while true; do dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ --inputbox "Type a new Password for User ${USER}" 0 70 "${CMDLINE[${NAME}]}" \ 2>${TMP_PATH}/resp [ $? -ne 0 ] && break 2 - VALUE="$(<"${TMP_PATH}/resp")" + VALUE=$(cat "${TMP_PATH}/resp") [ -n "${VALUE}" ] && break dialog --backtitle "$(backtitle)" --colors --title "Reset DSM Password" \ --msgbox "Invalid Password" 0 0 @@ -1904,7 +1904,7 @@ function bootipwaittime() { dialog --backtitle "$(backtitle)" --colors --title "Boot IP Waittime" \ --default-item "${BOOTIPWAIT}" --no-items --menu "Choose Waittime(seconds)\nto get an IP" 0 0 0 ${ITEMS} \ 2>"${TMP_PATH}/resp" - resp="$(cat ${TMP_PATH}/resp 2>/dev/null)" + resp=$(cat ${TMP_PATH}/resp) [ -z "${resp}" ] && return 1 BOOTIPWAIT=${resp} writeConfigKey "arc.bootipwait" "${BOOTIPWAIT}" "${USER_CONFIG_FILE}" @@ -1922,7 +1922,7 @@ function saveMenu() { mkdir -p "${RDXZ_PATH}" (cd "${RDXZ_PATH}"; xz -dc <"${PART3_PATH}/initrd-arc" | cpio -idm) >/dev/null 2>&1 || true rm -rf "${RDXZ_PATH}/opt/arc" - cp -Rf "/opt" "${RDXZ_PATH}" + cp -Rf "$(dirname ${ARC_PATH})" "${RDXZ_PATH}" (cd "${RDXZ_PATH}"; find . 2>/dev/null | cpio -o -H newc -R root:root | xz --check=crc32 >"${PART3_PATH}/initrd-arc") || true rm -rf "${RDXZ_PATH}" dialog --backtitle "$(backtitle)" --colors --aspect 18 \ @@ -1936,34 +1936,34 @@ function formatdisks() { while read -r KNAME KMODEL; do [ -z "${KNAME}" ] && continue [[ "${KNAME}" = /dev/md* ]] && continue - [ -z "${KMODEL}" ] && KMODEL="${TYPE}" + [ -z "${KMODEL}" ] && KMODEL="Partition" echo "${KNAME}" | grep -q "${LOADER_DISK}" && continue echo "\"${KNAME}\" \"${KMODEL}\" \"off\"" >>"${TMP_PATH}/opts" - done <<<$(lsblk -pno KNAME,MODEL,TYPE) + done <<<$(lsblk -pno KNAME,MODEL) if [ ! -f "${TMP_PATH}/opts" ]; then dialog --backtitle "$(backtitle)" --colors --title "Format Disks" \ --msgbox "No disk found!" 0 0 - return + return 1 fi dialog --backtitle "$(backtitle)" --colors --title "Format Disks" \ --checklist "Select Disk(s)" 0 0 0 --file "${TMP_PATH}/opts" \ 2>${TMP_PATH}/resp [ $? -ne 0 ] && return - RESP=$(<"${TMP_PATH}/resp") - [ -z "${RESP}" ] && return + resp=$(cat ${TMP_PATH}/resp) + [ -z "${resp}" ] && return dialog --backtitle "$(backtitle)" --colors --title "Format Disks" \ --yesno "Warning:\nThis operation is irreversible. Please backup important data. Do you want to continue?" 0 0 [ $? -ne 0 ] && return - if [ $(ls /dev/md* 2>/dev/null | wc -l) -gt 0 ]; then + if [ $(ls /dev/md[0-9]* 2>/dev/null | wc -l) -gt 0 ]; then dialog --backtitle "$(backtitle)" --colors --title "Format Disks" \ - --yesno "Warning:\nThe current HDD are in Raid, do you still want to format them?" 0 0 + --yesno "Warning:\nThe current HDD(s) are in Raid, do you still want to format them?" 0 0 [ $? -ne 0 ] && return - for I in $(ls /dev/md* 2>/dev/null); do + for I in $(ls /dev/md[0-9]* 2>/dev/null); do mdadm -S "${I}" done fi ( - for I in ${RESP}; do + for I in ${resp}; do if [[ "${I}" = /dev/mmc* ]]; then echo y | mkfs.ext4 -T largefile4 -E nodiscard "${I}" else @@ -1976,6 +1976,22 @@ function formatdisks() { --msgbox "Formatting is complete." 0 0 } +############################################################################### +# install opkg package manager +function package() { + dialog --backtitle "$(backtitle)" --colors --title "Package" \ + --yesno "This installs opkg Package Management,\nallowing you to install more Tools for use and debugging.\nDo you want to continue?" 0 0 + [ $? -ne 0 ] && return + ( + wget -O - http://bin.entware.net/x64-k3.2/installer/generic.sh | /bin/sh + opkg update + #opkg install python3 python3-pip + ) 2>&1 | dialog --backtitle "$(backtitle)" --colors --title "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 +} + ############################################################################### # let user format disks from inside arc function forcessh() { @@ -2008,6 +2024,78 @@ EOF --msgbox "${MSG}" 0 0 } +############################################################################### +# Clone Loader Disk +function cloneLoader() { + rm -f "${TMP_PATH}/opts" + while read -r KNAME KMODEL; do + [ -z "${KNAME}" ] && continue + [ -z "${KMODEL}" ] && KMODEL="${TYPE}" + echo "${KNAME}" | grep -q "${LOADER_DISK}" && continue + echo "\"${KNAME}\" \"${KMODEL}\" \"off\"" >>"${TMP_PATH}/opts" + done <<<$(lsblk -dpno KNAME,MODEL,TYPE) + if [ ! -f "${TMP_PATH}/opts" ]; then + dialog --backtitle "$(backtitle)" --colors --title "Clone Loader" \ + --msgbox "No disk found!" 0 0 + return + fi + dialog --backtitle "$(backtitle)" --colors --title "Clone Loader" \ + --radiolist "Choose a Destination" 0 0 0 --file "${TMP_PATH}/opts" \ + 2>${TMP_PATH}/resp + [ $? -ne 0 ] && return + resp=$(cat ${TMP_PATH}/resp) + if [ -z "${resp}" ]; then + dialog --backtitle "$(backtitle)" --colors --title "Clone Loader" \ + --msgbox "No disk selected!" 0 0 + return + else + SIZE=$(df -m ${resp} 2>/dev/null | awk 'NR==2 {print $2}') + if [ ${SIZE:-0} -lt 1024 ]; then + dialog --backtitle "$(backtitle)" --colors --title "Clone Loader" \ + --msgbox "Disk ${resp} size is less than 1GB and cannot be cloned!" 0 0 + return + fi + MSG="" + MSG+="Warning:\nDisk ${resp} will be formatted and written to the bootloader. Please confirm that important data has been backed up. \nDo you want to continue?" + dialog --backtitle "$(backtitle)" --colors --title "Clone Loader" \ + --yesno "${MSG}" 0 0 + [ $? -ne 0 ] && return + fi + ( + rm -rf "${PART3_PATH}/dl" + CLEARCACHE=0 + + gzip -dc "${CUSTOM_PATH}/grub.img.gz" | dd of="${resp}" bs=1M conv=fsync status=progress + hdparm -z "${resp}" # reset disk cache + fdisk -l "${resp}" + sleep 3 + + mkdir -p "${TMP_PATH}/sdX1" + mount "$(lsblk "${resp}" -pno KNAME,LABEL 2>/dev/null | grep ARC1 | awk '{print $1}')" "${TMP_PATH}/sdX1" + cp -vRf "${PART1_PATH}/". "${TMP_PATH}/sdX1/" + sync + umount "${TMP_PATH}/sdX1" + + mkdir -p "${TMP_PATH}/sdX2" + mount "$(lsblk "${resp}" -pno KNAME,LABEL 2>/dev/null | grep ARC2 | awk '{print $1}')" "${TMP_PATH}/sdX2" + cp -vRf "${PART2_PATH}/". "${TMP_PATH}/sdX2/" + sync + umount "${TMP_PATH}/sdX2" + + mkdir -p "${TMP_PATH}/sdX3" + mount "$(lsblk "${resp}" -pno KNAME,LABEL 2>/dev/null | grep ARC3 | awk '{print $1}')" "${TMP_PATH}/sdX3" + cp -vRf "${PART3_PATH}/". "${TMP_PATH}/sdX3/" + sync + umount "${TMP_PATH}/sdX3" + sleep 3 + ) 2>&1 | dialog --backtitle "$(backtitle)" --colors --title "Clone Loader" \ + --progressbox "Cloning ..." 20 100 + dialog --backtitle "$(backtitle)" --colors --title "Clone Loader" \ + --msgbox "Bootloader has been cloned to disk ${resp},\nplease remove the current bootloader disk!\nReboot?" 0 0 + rebootTo config + return +} + ############################################################################### # let user delete Loader Boot Files function resetLoader() { diff --git a/files/initrd/opt/arc/boot.sh b/files/initrd/opt/arc/boot.sh index 1d10ff5..0c6aa3f 100755 --- a/files/initrd/opt/arc/boot.sh +++ b/files/initrd/opt/arc/boot.sh @@ -11,30 +11,21 @@ BUS=$(getBus "${LOADER_DISK}") # Check if machine has EFI [ -d /sys/firmware/efi ] && EFI=1 || EFI=0 -# Print text centralized +# Print Title centralized clear COLUMNS=${COLUMNS:-50} -TITLE="${ARC_TITLE}" +BANNER="$(figlet -c -w "$(((${COLUMNS})))" "Arc-C Loader")" +TITLE="Version:" +TITLE+=" ${ARC_TITLE}" printf "\033[1;30m%*s\n" ${COLUMNS} "" printf "\033[1;30m%*s\033[A\n" ${COLUMNS} "" +printf "\033[1;34m%*s\033[0m\n" ${COLUMNS} "${BANNER}" printf "\033[1;34m%*s\033[0m\n" $(((${#TITLE} + ${COLUMNS}) / 2)) "${TITLE}" printf "\033[1;30m%*s\033[0m\n" ${COLUMNS} "" -TITLE="BOOTING:" -[ ${EFI} -eq 1 ] && TITLE+=" [UEFI]" || TITLE+=" [Legacy]" +[ ${EFI} -eq 1 ] && TITLE="[UEFI]" || TITLE="[Legacy]" TITLE+=" [${BUS}]" printf "\033[1;34m%*s\033[0m\n" $(((${#TITLE} + ${COLUMNS}) / 2)) "${TITLE}" -echo -cat </dev/null | grep "${1} " | awk -F':' '{print $(NF-1)}' | sed 's/_host//') echo "${BUS}" + return 0 } ############################################################################### @@ -211,6 +212,7 @@ function getIP() { [ -z "${IP}" ] && IP=$(ip addr show | grep -E "inet .* eth" | awk '{print $2}' | cut -f1 -d'/' | head -1) fi echo "${IP}" + return 0 } ############################################################################### @@ -306,6 +308,7 @@ EOF done rm -f ${TMP_PATH}/ethlist + return 0 } ############################################################################### @@ -389,7 +392,9 @@ function livepatch() { # Rebooting # (based on pocopico's TCRP code) function rebootTo() { - [[ "${1}" != "junior" && "${1}" != "config" ]] && exit 1 + MODES="config recovery junior" + [ -z "${1}" ] && exit 1 + if ! echo "${MODES}" | grep -qw "${1}"; then exit 1; fi # echo "Rebooting to ${1} mode" GRUBPATH="$(dirname $(find ${BOOTLOADER_PATH}/ -name grub.cfg | head -1))" ENVFILE="${GRUBPATH}/grubenv" diff --git a/files/initrd/opt/arc/include/network.sh b/files/initrd/opt/arc/include/network.sh index ad22eaa..88bae63 100755 --- a/files/initrd/opt/arc/include/network.sh +++ b/files/initrd/opt/arc/include/network.sh @@ -8,6 +8,7 @@ function getnet() { [ -n "${ARCMAC}" ] && writeConfigKey "mac.${ETH}" "${ARCMAC}" "${USER_CONFIG_FILE}" [ -z "${ARCMAC}" ] && break ARCMACNUM=$((${ARCMACNUM} + 1)) + ARCMAC="" done writeConfigKey "arc.macsys" "hardware" "${USER_CONFIG_FILE}" MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")" diff --git a/files/initrd/opt/arc/init.sh b/files/initrd/opt/arc/init.sh index 3fe434d..a8fc906 100755 --- a/files/initrd/opt/arc/init.sh +++ b/files/initrd/opt/arc/init.sh @@ -11,12 +11,15 @@ set -e # Get Loader Disk Bus BUS=$(getBus "${LOADER_DISK}") -# Shows title +# Print Title centralized clear -[ -z "${COLUMNS}" ] && COLUMNS=50 -TITLE="${ARC_TITLE}" +COLUMNS=${COLUMNS:-50} +BANNER="$(figlet -c -w "$(((${COLUMNS})))" "Arc-C Loader")" +TITLE="Version:" +TITLE+=" ${ARC_TITLE}" printf "\033[1;30m%*s\n" ${COLUMNS} "" printf "\033[1;30m%*s\033[A\n" ${COLUMNS} "" +printf "\033[1;34m%*s\033[0m\n" ${COLUMNS} "${BANNER}" printf "\033[1;34m%*s\033[0m\n" $(((${#TITLE} + ${COLUMNS}) / 2)) "${TITLE}" printf "\033[1;30m%*s\033[0m\n" ${COLUMNS} "" @@ -106,10 +109,11 @@ writeConfigKey "device.nic" "${NIC}" "${USER_CONFIG_FILE}" VID="0x46f4" PID="0x0001" +BUSLIST="usb sata scsi nvme mmc" if [ "${BUS}" = "usb" ]; then VID="0x$(udevadm info --query property --name "${LOADER_DISK}" | grep ID_VENDOR_ID | cut -d= -f2)" PID="0x$(udevadm info --query property --name "${LOADER_DISK}" | grep ID_MODEL_ID | cut -d= -f2)" -elif [[ "${BUS}" != "sata" && "${BUS}" != "scsi" && "${BUS}" != "nvme" && "${BUS}" != "mmc" ]]; then +elif ! echo "${BUSLIST}" | grep -wq "${BUS}"; then die "Loader disk is not USB or SATA/SCSI/NVME/eMMC DoM" fi diff --git a/scripts/func.sh b/scripts/func.sh index 14df936..be4f361 100755 --- a/scripts/func.sh +++ b/scripts/func.sh @@ -103,6 +103,7 @@ function getAddons() { echo "Extracting ${PKG} to ${DEST_PATH}/${ADDON}" tar -xaf "${PKG}" -C "${DEST_PATH}/${ADDON}" done + rm -f "${CACHE_FILE}" echo "Getting Addons end - ${TAG}" }