arc-v: cleanup

Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
AuxXxilium 2024-02-13 20:28:22 +01:00
parent 105fb16de2
commit cdae1d332c

View File

@ -17,71 +17,6 @@ printf "\033[1;30m%*s\033[A\n" ${COLUMNS} ""
printf "\033[1;34m%*s\033[0m\n" $(((${#TITLE} + ${COLUMNS}) / 2)) "${TITLE}"
printf "\033[1;30m%*s\033[0m\n" ${COLUMNS} ""
# If user config file not exists, initialize it
if [ ! -f "${USER_CONFIG_FILE}" ]; then
touch "${USER_CONFIG_FILE}"
fi
initConfigKey "lkm" "prod" "${USER_CONFIG_FILE}"
initConfigKey "model" "" "${USER_CONFIG_FILE}"
initConfigKey "productver" "" "${USER_CONFIG_FILE}"
initConfigKey "layout" "qwertz" "${USER_CONFIG_FILE}"
initConfigKey "keymap" "de" "${USER_CONFIG_FILE}"
initConfigKey "zimage-hash" "" "${USER_CONFIG_FILE}"
initConfigKey "ramdisk-hash" "" "${USER_CONFIG_FILE}"
initConfigKey "cmdline" "{}" "${USER_CONFIG_FILE}"
initConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}"
initConfigKey "addons" "{}" "${USER_CONFIG_FILE}"
initConfigKey "addons.acpid" "" "${USER_CONFIG_FILE}"
initConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
initConfigKey "arc" "{}" "${USER_CONFIG_FILE}"
initConfigKey "arc.confdone" "false" "${USER_CONFIG_FILE}"
initConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}"
initConfigKey "arc.paturl" "" "${USER_CONFIG_FILE}"
initConfigKey "arc.pathash" "" "${USER_CONFIG_FILE}"
initConfigKey "arc.sn" "" "${USER_CONFIG_FILE}"
initConfigKey "arc.mac1" "" "${USER_CONFIG_FILE}"
initConfigKey "arc.staticip" "false" "${USER_CONFIG_FILE}"
initConfigKey "arc.ipv6" "false" "${USER_CONFIG_FILE}"
initConfigKey "arc.offline" "false" "${USER_CONFIG_FILE}"
initConfigKey "arc.directboot" "false" "${USER_CONFIG_FILE}"
initConfigKey "arc.remap" "" "${USER_CONFIG_FILE}"
initConfigKey "arc.usbmount" "false" "${USER_CONFIG_FILE}"
initConfigKey "arc.patch" "random" "${USER_CONFIG_FILE}"
initConfigKey "arc.pathash" "" "${USER_CONFIG_FILE}"
initConfigKey "arc.paturl" "" "${USER_CONFIG_FILE}"
initConfigKey "arc.bootipwait" "20" "${USER_CONFIG_FILE}"
initConfigKey "arc.bootwait" "0" "${USER_CONFIG_FILE}"
initConfigKey "arc.kernelload" "power" "${USER_CONFIG_FILE}"
initConfigKey "arc.kernelpanic" "5" "${USER_CONFIG_FILE}"
initConfigKey "arc.macsys" "hardware" "${USER_CONFIG_FILE}"
initConfigKey "arc.bootcount" "0" "${USER_CONFIG_FILE}"
initConfigKey "arc.odp" "false" "${USER_CONFIG_FILE}"
initConfigKey "arc.hddsort" "false" "${USER_CONFIG_FILE}"
initConfigKey "arc.version" "${ARC_VERSION}" "${USER_CONFIG_FILE}"
initConfigKey "device" "{}" "${USER_CONFIG_FILE}"
# Init Network
ETHX=$(ls /sys/class/net/ | grep -v lo | grep -v docker || true)
ETH=$(echo ${ETHX} | wc -w)
# No network devices
[ ${ETH} -le 0 ] && die "No NIC found! - Loader does not work without Network connection."
MACSYS="$(readConfigKey "arc.macsys" "${USER_CONFIG_FILE}")"
if [ "${MACSYS}" = "custom" ]; then
MACR="$(cat /sys/class/net/eth0/address | sed 's/://g')"
MACA="$(readConfigKey "arc.mac1" "${USER_CONFIG_FILE}")"
if [[ -n "${MACA}" && "${MACA}" != "${MACR}" ]]; then
MAC="${MACA:0:2}:${MACA:2:2}:${MACA:4:2}:${MACA:6:2}:${MACA:8:2}:${MACA:10:2}"
echo "Setting eth0 MAC to ${MAC}"
ip link set dev eth0 address "${MAC}" >/dev/null 2>&1 &&
(/etc/init.d/S41dhcpcd restart >/dev/null 2>&1 &) || true
sleep 2
elif [ -z "${MACA}" ]; then
# Write real Mac to cmdline config
writeConfigKey "arc.mac1" "${MACR}" "${USER_CONFIG_FILE}"
fi
echo
fi
# Get the VID/PID if we are in USB
VID="0x46f4"
PID="0x0001"
@ -94,61 +29,18 @@ elif [[ "${BUS}" != "sata" && "${BUS}" != "scsi" && "${BUS}" != "nvme" ]]; then
die "Loader disk is not USB or SATA/SCSI/NVME DoM"
fi
# Save variables to user config file
writeConfigKey "vid" ${VID} "${USER_CONFIG_FILE}"
writeConfigKey "pid" ${PID} "${USER_CONFIG_FILE}"
# Inform user
echo -e "Loader Disk: \033[1;34m${LOADER_DISK}\033[0m"
echo -e "Loader Disk Type: \033[1;34m${BUS^^}\033[0m"
# Load keymap name
LAYOUT="$(readConfigKey "layout" "${USER_CONFIG_FILE}")"
KEYMAP="$(readConfigKey "keymap" "${USER_CONFIG_FILE}")"
# Loads a keymap if is valid
if [ -f "/usr/share/keymaps/i386/${LAYOUT}/${KEYMAP}.map.gz" ]; then
echo -e "Loading Keymap: \033[1;34m${LAYOUT}/${KEYMAP}\033[0m"
zcat "/usr/share/keymaps/i386/${LAYOUT}/${KEYMAP}.map.gz" | loadkeys
fi
echo
# Grep Config Values
BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")"
# Decide if boot automatically
if grep -q "force_arc" /proc/cmdline; then
echo -e "\033[1;34mUser requested edit settings.\033[0m"
elif [ "${BUILDDONE}" = "true" ]; then
echo -e "\033[1;34mLoader is configured!\033[0m"
boot.sh && exit 0
else
echo -e "\033[1;34mUser requested edit settings.\033[0m"
fi
echo
BOOTCOUNT="$(readConfigKey "arc.bootcount" "${USER_CONFIG_FILE}")"
[ -z "${BOOTCOUNT}" ] && BOOTCOUNT=0
STATICIP="$(readConfigKey "arc.staticip" "${USER_CONFIG_FILE}")"
BOOTIPWAIT="$(readConfigKey "arc.bootipwait" "${USER_CONFIG_FILE}")"
[ -z "${BOOTIPWAIT}" ] && BOOTIPWAIT=20
echo -e "\033[1;34mDetected ${ETH} NIC.\033[0m \033[1;37mWaiting for Connection:\033[0m"
for N in ${ETHX}; do
IP=""
DRIVER=$(ls -ld /sys/class/net/${N}/device/driver 2>/dev/null | awk -F '/' '{print $NF}')
COUNT=0
while true; do
if [[ "${STATICIP}" = "true" && "${N}" = "eth0" && -n "${ARCIP}" && ${BOOTCOUNT} -gt 0 ]]; then
ARCIP="$(readConfigKey "arc.ip" "${USER_CONFIG_FILE}")"
NETMASK="$(readConfigKey "arc.netmask" "${USER_CONFIG_FILE}")"
IP="${ARCIP}"
NETMASK=$(convert_netmask "${NETMASK}")
ip addr add ${IP}/${NETMASK} dev eth0
MSG="STATIC"
else
IP="$(getIP ${N})"
MSG="DHCP"
fi
if [ -n "${IP}" ]; then
SPEED=$(ethtool ${N} | grep "Speed:" | awk '{print $2}')
echo -e "\r\033[1;37m${DRIVER} (${SPEED} | ${MSG}):\033[0m Access \033[1;34mhttp://${IP}:7681\033[0m to connect to Arc via web."
@ -172,7 +64,6 @@ done
echo
echo -e "Call \033[1;34marc.sh\033[0m to configure Arc-V"
echo
echo -e "User config is on \033[1;34m${USER_CONFIG_FILE}\033[0m"
echo -e "Default SSH Root password is \033[1;34marc\033[0m"
echo
@ -199,5 +90,5 @@ elif [ ${HASATA} = "0" ]; then
echo -e "\033[1;31m*** Please insert at least one Sata/SAS Disk for System Installation, except for the Bootloader Disk. ***\033[0m\n"
echo -e "\033[1;31mUse arc.sh to proceed. Not recommended!\033[0m\n"
else
arc.sh
sysctl -p /etc/sysctl.conf
fi