Skip to content

Commit

Permalink
Merge pull request #2160 from AuxXxilium/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AuxXxilium authored Jun 27, 2024
2 parents 2f4ce28 + e1f8c28 commit 28b6908
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 115 deletions.
8 changes: 4 additions & 4 deletions files/initrd/opt/arc/arc-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,8 @@ function sysinfo() {
# Get System Informations
CPU=$(echo $(cat /proc/cpuinfo 2>/dev/null | grep 'model name' | uniq | awk -F':' '{print $2}'))
VENDOR=$(dmesg 2>/dev/null | grep -i "DMI:" | sed 's/\[.*\] DMI: //i')
ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth)
ETHN=$(ls /sys/class/net/ 2>/dev/null | grep eth | wc -l)
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)"
ETHN="${#ETHX}"
CONFDONE="$(readConfigKey "arc.confdone" "${USER_CONFIG_FILE}")"
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
if [ "${CONFDONE}" == "true" ]; then
Expand Down Expand Up @@ -1269,7 +1269,7 @@ function sysinfo() {
# Shows Networkdiag to user
function networkdiag() {
(
ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) # real network cards list
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)"
for ETH in ${ETHX}; do
echo
DRIVER=$(ls -ld /sys/class/net/${ETH}/device/driver 2>/dev/null | awk -F '/' '{print $NF}')
Expand Down Expand Up @@ -1357,7 +1357,7 @@ function credits() {
###############################################################################
# allow setting Static IP for Loader
function staticIPMenu() {
ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) # real network cards list
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)"
for ETH in ${ETHX}; do
MACR="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g')"
IPR="$(readConfigKey "network.${MACR}" "${USER_CONFIG_FILE}")"
Expand Down
37 changes: 16 additions & 21 deletions files/initrd/opt/arc/arc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RAMTOTAL=$(awk '/MemTotal:/ {printf "%.0f", $2 / 1024 / 1024}' /proc/meminfo 2>/
if grep -q "^flags.*hypervisor.*" /proc/cpuinfo; then
MACHINE="$(lscpu | grep Hypervisor | awk '{print $3}')" # KVM or VMware
else
MACHINE="NATIVE"
MACHINE="Native"
fi
# Check for AES and ACPI Support
if ! grep -q "^flags.*aes.*" /proc/cpuinfo; then
Expand All @@ -43,14 +43,14 @@ BUS=$(getBus "${LOADER_DISK}")
ARCNIC="$(readConfigKey "arc.nic" "${USER_CONFIG_FILE}")"
OFFLINE="$(readConfigKey "arc.offline" "${USER_CONFIG_FILE}")"
CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")"
NEWTAG=$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)
NEWTAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
if [ -n "${NEWTAG}" ]; then
[ -z "${ARCNIC}" ] && ARCNIC="auto"
elif [ -z "${NEWTAG}" ]; then
ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) # real network cards list
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)"
for ETH in ${ETHX}; do
# Update Check
NEWTAG=$(curl --interface ${ETH} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)
NEWTAG="$(curl --interface ${ETH} -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)"
if [ -n "${NEWTAG}" ]; then
[ -z "${ARCNIC}" ] && ARCNIC="${ETH}"
break
Expand Down Expand Up @@ -117,13 +117,13 @@ KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
if [ "${OFFLINE}" == "false" ]; then
# Timezone
if [ "${ARCNIC}" == "auto" ]; then
REGION=$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)
TIMEZONE=$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)
[ -z "${KEYMAP}" ] && KEYMAP=$(curl -m 5 -v "http://ip-api.com/line?fields=countryCode" 2>/dev/null | tr '[:upper:]' '[:lower:]')
REGION="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
TIMEZONE="$(curl -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
[ -z "${KEYMAP}" ] && KEYMAP="$(curl -m 5 -v "http://ip-api.com/line?fields=countryCode" 2>/dev/null | tr '[:upper:]' '[:lower:]')"
else
REGION=$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)
TIMEZONE=$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)
[ -z "${KEYMAP}" ] && KEYMAP=$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=countryCode" 2>/dev/null | tr '[:upper:]' '[:lower:]')
REGION="$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f1)"
TIMEZONE="$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=timezone" 2>/dev/null | tr -d '\n' | cut -d '/' -f2)"
[ -z "${KEYMAP}" ] && KEYMAP="$(curl --interface ${ARCNIC} -m 5 -v "http://ip-api.com/line?fields=countryCode" 2>/dev/null | tr '[:upper:]' '[:lower:]')"
fi
writeConfigKey "time.region" "${REGION}" "${USER_CONFIG_FILE}"
writeConfigKey "time.timezone" "${TIMEZONE}" "${USER_CONFIG_FILE}"
Expand Down Expand Up @@ -549,11 +549,6 @@ function arcSettings() {
if [ "${ACPISYS}" == "false" ]; then
dialog --backtitle "$(backtitle)" --title "Arc Warning" \
--msgbox "WARN: Your System doesn't support CPU Frequency Scaling in DSM. (ACPI)" 5 80
else
if [ "${PLATFORM}" != "epyc7002" ]; then
echo "N cpufreq_conservative.ko" >>"${USER_UP_PATH}/modulelist"
echo "N cpufreq_ondemand.ko" >>"${USER_UP_PATH}/modulelist"
fi
fi
fi
EMMCBOOT="$(readConfigKey "arc.emmcboot" "${USER_CONFIG_FILE}")"
Expand Down Expand Up @@ -689,9 +684,9 @@ function make() {
idx=0
while [ ${idx} -le 3 ]; do # Loop 3 times, if successful, break
if [ "${ARCNIC}" == "auto" ]; then
PAT_DATA=$(curl -skL -m 10 "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}")
PAT_DATA="$(curl -skL -m 10 "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}")"
else
PAT_DATA=$(curl --interface ${ARCNIC} -skL -m 10 "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}")
PAT_DATA="$(curl --interface ${ARCNIC} -skL -m 10 "https://www.synology.com/api/support/findDownloadInfo?lang=en-us&product=${MODEL/+/%2B}&major=${PRODUCTVER%%.*}&minor=${PRODUCTVER##*.}")"
fi
if [ "$(echo ${PAT_DATA} | jq -r '.success' 2>/dev/null)" == "true" ]; then
if echo ${PAT_DATA} | jq -r '.info.system.detail[0].items[0].files[0].label_ext' 2>/dev/null | grep -q 'pat'; then
Expand All @@ -715,11 +710,11 @@ function make() {
idx=0
while [ ${idx} -le 3 ]; do # Loop 3 times, if successful, break
if [ "${ARCNIC}" == "auto" ]; then
PAT_URL=$(curl -skL -m 10 "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_url")
PAT_HASH=$(curl -skL -m 10 "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_hash")
PAT_URL="$(curl -skL -m 10 "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_url")"
PAT_HASH="$(curl -skL -m 10 "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_hash")"
else
PAT_URL=$(curl --interface ${ARCNIC} -m 10 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_url")
PAT_HASH=$(curl --interface ${ARCNIC} -m 10 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_hash")
PAT_URL="$(curl --interface ${ARCNIC} -m 10 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_url")"
PAT_HASH="$(curl --interface ${ARCNIC} -m 10 -skL "https://raw.githubusercontent.com/AuxXxilium/arc-dsm/main/dsm/${MODEL/+/%2B}/${PRODUCTVER}/pat_hash")"
fi
PAT_URL=${PAT_URL%%\?*}
if [ -n "${PAT_URL}" ] && [ -n "${PAT_HASH}" ]; then
Expand Down
17 changes: 13 additions & 4 deletions files/initrd/opt/arc/boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,23 @@ fi

# Cmdline NIC Settings
ETHN=0
ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth)
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
if [ "${ARCPATCH}" == "true" ]; then
NICPORTS="$(readConfigKey "${MODEL}.ports" "${S_FILE}" 2>/dev/null)"
[ -z "${NICPORTS}" ] && NICPORTS=1
else
NICPORTS=$(ls /sys/class/net/ 2>/dev/null | grep eth | wc -l)
fi
for ETH in ${ETHX}; do
MAC="$(readConfigKey "arc.${ETH}" "${USER_CONFIG_FILE}")"
[ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g')"
[ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')"
ETHN=$((${ETHN} + 1))
CMDLINE['mac${ETHN}']="${MAC}"
if [ ${ETHN} -le ${NICPORTS} ]; then
CMDLINE['mac${ETHN}']="${MAC}"
fi
done
CMDLINE['netif_num']="${ETHN}"
CMDLINE['netif_num']="${NICPORTS}"

# Read user network settings
while IFS=': ' read -r KEY VALUE; do
Expand Down
75 changes: 24 additions & 51 deletions files/initrd/opt/arc/include/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,66 +209,39 @@ function _set_conf_kv() {
# @1 -mac1,mac2,mac3...
function _sort_netif() {
ETHLIST=""
ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) # real network cards list
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list
for ETH in ${ETHX}; do
MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')"
ETHBUS=$(ethtool -i ${ETH} 2>/dev/null | grep bus-info | awk '{print $2}')
BUS="$(ethtool -i ${ETH} 2>/dev/null | grep bus-info | cut -d' ' -f2)"
ETHLIST="${ETHLIST}${BUS} ${MAC} ${ETH}\n"
done

ETHLISTTMPM=""
ETHLISTTMPB="$(echo -e "${ETHLIST}" | sort)"
if [ -n "${1}" ]; then
MACS=$(echo "${1}" | sed 's/://g' | tr '[:upper:]' '[:lower:]' | tr ',' ' ')
ETHLISTTMPC=""
ETHLISTTMPF=""

MACS="$(echo "${1}" | sed 's/://g' | tr '[:upper:]' '[:lower:]' | tr ',' ' ')"
for MACX in ${MACS}; do
ETHLISTTMPC="${ETHLISTTMPC}$(echo -e "${ETHLIST}" | grep "${MACX}")\n"
ETHLISTTMPM="${ETHLISTTMPM}$(echo -e "${ETHLISTTMPB}" | grep "${MACX}")\n"
ETHLISTTMPB="$(echo -e "${ETHLISTTMPB}" | grep -v "${MACX}")\n"
done

while read -r ETHBUS MAC ETH; do
[ -z "${MAC}" ] && continue
if echo "${MACS}" | grep -q "${MAC}"; then continue; fi
ETHLISTTMPF="${ETHLISTTMPF}${ETHBUS} ${MAC} ${ETH}\n"
done <<EOF
$(echo -e ${ETHLIST} | sort)
EOF
ETHLIST="${ETHLISTTMPC}${ETHLISTTMPF}"
else
ETHLIST="$(echo -e "${ETHLIST}" | sort)"
fi
ETHLIST="$(echo -e "${ETHLIST}" | grep -v '^$')"

echo -e "${ETHLIST}" >${TMP_PATH}/ethlist
# cat ${TMP_PATH}/ethlist

ETHLIST="$(echo -e "${ETHLISTTMPM}${ETHLISTTMPB}" | grep -v '^$')"
ETHSEQ="$(echo -e "${ETHLIST}" | awk '{print $3}' | sed 's/eth//g')"
ETHNUM="$(echo -e "${ETHLIST}" | wc -l)"
# sort
IDX=0
while true; do
# cat ${TMP_PATH}/ethlist
[ ${IDX} -ge $(wc -l <${TMP_PATH}/ethlist) ] && break
ETH=$(cat ${TMP_PATH}/ethlist | sed -n "$((${IDX} + 1))p" | awk '{print $3}')
# echo "ETH: ${ETH}"
if [ -n "${ETH}" ] && [ "${ETH}" != "eth${IDX}" ]; then
# echo "change ${ETH} <=> eth${IDX}"
ip link set dev eth${IDX} down
ip link set dev ${ETH} down
sleep 1
ip link set dev eth${IDX} name ethN
ip link set dev ${ETH} name eth${IDX}
ip link set dev ethN name ${ETH}
sleep 1
ip link set dev eth${IDX} up
ip link set dev ${ETH} up
sleep 1
sed -i "s/eth${IDX}/ethN/" ${TMP_PATH}/ethlist
sed -i "s/${ETH}/eth${IDX}/" ${TMP_PATH}/ethlist
sed -i "s/ethN/${ETH}/" ${TMP_PATH}/ethlist
sleep 1
fi
IDX=$((${IDX} + 1))
done

rm -f ${TMP_PATH}/ethlist
if [ ! "${ETHSEQ}" = "$(seq 0 $((${ETHNUM:0} - 1)))" ]; then
/etc/init.d/S41dhcpcd stop >/dev/null 2>&1
/etc/init.d/S40network stop >/dev/null 2>&1
for i in $(seq 0 $((${ETHNUM:0} - 1))); do
ip link set dev eth${i} name tmp${i}
done
local I=0
for i in ${ETHSEQ}; do
ip link set dev tmp${i} name eth${I}
I=$((${I} + 1))
done
/etc/init.d/S40network start >/dev/null 2>&1
/etc/init.d/S41dhcpcd start >/dev/null 2>&1
fi
return 0
}

Expand Down
5 changes: 5 additions & 0 deletions files/initrd/opt/arc/include/modulelist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ N kvm-intel.ko
N kvm-amd.ko
N kvm.ko

# acpi
N acpi_call.ko
N cpufreq_conservative.ko
N cpufreq_ondemand.ko

# sensors
N coretemp.ko
N k10temp.ko
Expand Down
13 changes: 7 additions & 6 deletions files/initrd/opt/arc/include/network.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Get Network Config for Loader
function getnet() {
ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) # real network cards list
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)" # real network cards list
MODEL="$(readConfigKey "model" "${USER_CONFIG_FILE}")"
ARCPATCH="$(readConfigKey "arc.patch" "${USER_CONFIG_FILE}")"
NICPORTS="$(readConfigKey "${MODEL}.ports" "${S_FILE}" 2>/dev/null)"
if [ "${ARCPATCH}" == "true" ]; then
ETHN=$(ls /sys/class/net/ 2>/dev/null | grep eth | wc -l)
ETHN="${#ETHX}"
MACS=($(generateMacAddress "${MODEL}" ${ETHN} true))
for I in $(seq 1 ${ETHN}); do
writeConfigKey "arc.eth$((${I} - 1))" "${MACS[$((${I} - 1))]}" "${USER_CONFIG_FILE}"
Expand All @@ -21,13 +22,13 @@ function getnet() {
while true; do
MAC="$(cat /sys/class/net/${ETH}/address | sed 's/://g')"
dialog --backtitle "$(backtitle)" --title "Mac Setting" \
--inputbox "Type a custom MAC for ${ETH} (Eq. 001132123456)." 7 50 "${MAC}"\
--inputbox "Type a custom MAC for ${ETH} (Eq. 001132abc123)." 7 50 "${MAC}"\
2>"${TMP_PATH}/resp"
[ $? -ne 0 ] && break
MAC=$(cat "${TMP_PATH}/resp")
[ -z "${MAC}" ] && MAC="$(readConfigKey "arc.${ETH}" "${USER_CONFIG_FILE}")"
[ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address | sed 's/://g')"
MAC="$(echo "${MAC}" | sed "s/:\|-\| //g")"
[ -z "${MAC}" ] && MAC="$(cat /sys/class/net/${ETH}/address 2>/dev/null | sed 's/://g' | tr '[:upper:]' '[:lower:]')"
MAC="$(echo "${MAC}" | sed "s/:\|-\| //g" | tr '[:upper:]' '[:lower:]')"
if [ ${#MAC} -eq 12 ]; then
writeConfigKey "arc.${ETH}" "${MAC}" "${USER_CONFIG_FILE}"
break
Expand All @@ -40,7 +41,7 @@ function getnet() {
}

# Get Amount of NIC
ETHX=$(ls /sys/class/net/ 2>/dev/null | grep eth) # real network cards list
ETHX="$(ls /sys/class/net/ 2>/dev/null | grep eth)"
# Get actual IP
for ETH in ${ETHX}; do
IPCON=$(getIP ${ETH})
Expand Down
6 changes: 3 additions & 3 deletions files/initrd/opt/arc/include/storage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function getmap() {
if [ $(lspci -d ::106 | wc -l) -gt 0 ]; then
LASTDRIVE=0
while read -r D; do
if [ "${BUS}" == "sata" ] && [ "${MACHINE}" != "NATIVE" ] && [ ${D} -eq 0 ]; then
if [ "${BUS}" == "sata" ] && [ "${MACHINE}" != "Native" ] && [ ${D} -eq 0 ]; then
MAXDISKS=${DRIVES}
echo -n "${D}>${MAXDISKS}:">>"${TMP_PATH}/remap"
elif [ ${D} != ${LASTDRIVE} ]; then
Expand All @@ -144,7 +144,7 @@ function getmapSelection() {
CUSTOM="$(readConfigKey "arc.custom" "${USER_CONFIG_FILE}")"
if [ "${CUSTOM}" == "false" ]; then
# Show recommended Option to user
if [ -n "${SATAREMAP}" ] && [ "${EXTERNALCONTROLLER}" == "true" ] && [ "${MACHINE}" == "NATIVE" ]; then
if [ -n "${SATAREMAP}" ] && [ "${EXTERNALCONTROLLER}" == "true" ] && [ "${MACHINE}" == "Native" ]; then
REMAP2="*"
elif [ -n "${SATAREMAP}" ] && [ "${EXTERNALCONTROLLER}" == "false" ]; then
REMAP3="*"
Expand Down Expand Up @@ -176,7 +176,7 @@ function getmapSelection() {
fi
else
# Show recommended Option to user
if [ -n "${SATAREMAP}" ] && [ "${EXTERNALCONTROLLER}" == "true" ] && [ "${MACHINE}" == "NATIVE" ]; then
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}"
Expand Down
Loading

0 comments on commit 28b6908

Please sign in to comment.