Merge pull request #48 from fbelavenuto/dev

Fixing custom MAC address
This commit is contained in:
Fabio Belavenuto 2022-07-21 14:26:12 -03:00 committed by GitHub
commit 45e4c75b23
19 changed files with 60 additions and 9 deletions

View File

@ -6,8 +6,12 @@ It is still in alpha stage, with little documentation, but it is functional. I'm
I tried to make the system as user-friendly as possible, to make life easier. The loader automatically detects which device is being used, SATADom or USB, detecting its VID and PID correctly. redpill-lkm has been edited to allow booting the kernel without setting the variables related to network interfaces so the loader (and user) doesn't have to worry about that. The Jun's code that makes the zImage and Ramdisk patch is embedded, if there is a change in "zImage" or "rd.gz" by some update, the loader re-applies the patches. Builds 42218 and 42661 up to update5 are working. Automatic updates should still be disabled as we are not sure if this technique will work forever. The most important kernel modules are built into the DSM ramdisk image for automatic peripheral detection. I tried to make the system as user-friendly as possible, to make life easier. The loader automatically detects which device is being used, SATADom or USB, detecting its VID and PID correctly. redpill-lkm has been edited to allow booting the kernel without setting the variables related to network interfaces so the loader (and user) doesn't have to worry about that. The Jun's code that makes the zImage and Ramdisk patch is embedded, if there is a change in "zImage" or "rd.gz" by some update, the loader re-applies the patches. Builds 42218 and 42661 up to update5 are working. Automatic updates should still be disabled as we are not sure if this technique will work forever. The most important kernel modules are built into the DSM ramdisk image for automatic peripheral detection.
# Use
To use this project, download the latest image available and burn it to a USB stick or SATA disk-on-module. Set the PC to boot from the burned media and follow the informations on the screen. When booting, the user can call the "menu.sh" command from the computer itself, access via SSH or use the virtual terminal (ttyd) by typing the address provided on the screen (http://(ip):7681). The loader will automatically increase the size of the last partition and use this space as cache if it is larger than 2GiB. To use this project, download the latest image available and burn it to a USB stick or SATA disk-on-module. Set the PC to boot from the burned media and follow the informations on the screen. When booting, the user can call the "menu.sh" command from the computer itself, access via SSH or use the virtual terminal (ttyd) by typing the address provided on the screen (http://(ip):7681). The loader will automatically increase the size of the last partition and use this space as cache if it is larger than 2GiB.
## It is highly recommended to use an SSD for the loader in the case of the option via DoM or a fast USB flash drive
The menu system is dynamic and I hope it is intuitive enough that the user can use it without any problems. Its allows you to choose a model, the existing buildnumber for the chosen model, type or randomly create a serial number, add/remove addons, add/remove/view "cmdline" and "synoinfo" entries, choose the LKM version, create the loader, boot, manually edit the configuration file, choose a keymap, update and exit. The menu system is dynamic and I hope it is intuitive enough that the user can use it without any problems. Its allows you to choose a model, the existing buildnumber for the chosen model, type or randomly create a serial number, add/remove addons, add/remove/view "cmdline" and "synoinfo" entries, choose the LKM version, create the loader, boot, manually edit the configuration file, choose a keymap, update and exit.
Changing addons and synoinfo entries require re-creating the loader, cmdline entries do not. You can view the "cmdline" and "synoinfo" entries defined for the chosen model, with user-defined entries having higher priority. Changing addons and synoinfo entries require re-creating the loader, cmdline entries do not. You can view the "cmdline" and "synoinfo" entries defined for the chosen model, with user-defined entries having higher priority.
@ -20,7 +24,8 @@ Another important point is that the loader detects whether or not the CPU has th
I developed a simple patch to no longer display the DUMMY port error on models without device-tree, the user will be able to install without having to worry about it. I developed a simple patch to no longer display the DUMMY port error on models without device-tree, the user will be able to install without having to worry about it.
# Thanks
All code was based on the work of TTG, pocopico, jumkey and others involved in continuing TTG's original redpill-load project. All code was based on the work of TTG, pocopico, jumkey and others involved in continuing TTG's original redpill-load project.
More information will be added in the future. More information will be added in the future.

5
TODO
View File

@ -2,7 +2,6 @@ A fazer
- Descobrir como é o serial do DS2422+ - Descobrir como é o serial do DS2422+
- Estudar acrescentar modo simples e avançado do menu - Estudar acrescentar modo simples e avançado do menu
- Mudar synoinfo para ler do modelo e preencher no user_config, para usuário poder deletar entradas do modelo - Mudar synoinfo para ler do modelo e preencher no user_config, para usuário poder deletar entradas do modelo
- Acertar flag DIRTY ao atualizar módulos, etc
Concluidos: Concluidos:
- Generalizar código dos addons - Generalizar código dos addons
@ -26,5 +25,5 @@ Concluidos:
- Melhorar opções de HD, talvez criar um menu a parte - Melhorar opções de HD, talvez criar um menu a parte
- Implementar update do bzimage e ramdisk online - Implementar update do bzimage e ramdisk online
- Mudar addons para colocar pacote completo na partição 3 e detectar dinâmicamente durante o boot do júnior - Mudar addons para colocar pacote completo na partição 3 e detectar dinâmicamente durante o boot do júnior
- Acertar flag DIRTY ao atualizar módulos, etc
https://kb.synology.com/en-me/DSM/tutorial/What_kind_of_CPU_does_my_NAS_have - Consertar MAC custom

View File

@ -1 +1 @@
0.3-alpha3 0.3-alpha4

View File

@ -0,0 +1,33 @@
#!/bin/sh
#
# Start/stop dhcpcd
#
DAEMON=/usr/sbin/dhcpcd
CONFIG=/etc/dhcpcd.conf
PIDFILE=/var/run/dhcpcd/pid
[ -f $CONFIG ] || exit 0
case "$1" in
start)
echo "Starting dhcpcd..."
start-stop-daemon -S -x "$DAEMON" -p "$PIDFILE" -- -f "$CONFIG"
;;
stop)
echo "Stopping dhcpcd..."
start-stop-daemon -K -x "$DAEMON" -p "$PIDFILE" -o
;;
reload|force-reload)
echo "Reloading dhcpcd configuration..."
"$DAEMON" -s reload
;;
restart)
"$0" stop
sleep 1 # Prevent race condition: ensure dhcpcd stops before start.
"$0" start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}"
exit 1
esac

View File

@ -102,18 +102,19 @@ echo -e "Cmdline:\n\033[1;36m${CMDLINE_LINE}\033[0m"
# Wait for an IP # Wait for an IP
COUNT=0 COUNT=0
echo -n "IP: " echo -n "IP"
while true; do while true; do
IP=`ip route get 1.1.1.1 2>/dev/null | awk '{print$7}'` IP=`ip route get 1.1.1.1 2>/dev/null | awk '{print$7}'`
if [ -n "${IP}" ]; then if [ -n "${IP}" ]; then
echo -e "\033[1;32m${IP}\033[0m" echo -e ": \033[1;32m${IP}\033[0m"
break break
elif [ ${COUNT} -eq 15 ]; then elif [ ${COUNT} -eq 15 ]; then
echo -e "\033[1;31mERROR\033[0m" echo -e ": \033[1;31mERROR\033[0m"
break break
fi fi
COUNT=$((${COUNT}+1)) COUNT=$((${COUNT}+1))
sleep 1 sleep 1
echo -n "."
done done
echo -e "\033[1;37mLoading DSM kernel...\033[0m" echo -e "\033[1;37mLoading DSM kernel...\033[0m"

View File

@ -1,5 +1,5 @@
ARPL_VERSION="0.3-alpha3" ARPL_VERSION="0.3-alpha4"
# Define paths # Define paths
TMP_PATH="/tmp" TMP_PATH="/tmp"

View File

@ -59,6 +59,14 @@ if [ ! -f "${USER_CONFIG_FILE}" ]; then
writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}" writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}"
fi fi
# Set custom MAC if defined
MAC1=`readConfigKey "cmdline.mac1" "${USER_CONFIG_FILE}"`
if [ -n "${MAC1}" ]; then
MAC="${MAC1:0:2}:${MAC1:2:2}:${MAC1:4:2}:${MAC1:6:2}:${MAC1:8:2}:${MAC1:10:2}"
ip link set dev eth0 address ${MAC} >/dev/null 2>&1 && \
(/etc/init.d/S41dhcpcd restart >/dev/null 2>&1 &) || true
fi
# Get the VID/PID if we are in USB # Get the VID/PID if we are in USB
VID="0x0000" VID="0x0000"
PID="0x0000" PID="0x0000"

View File

@ -315,6 +315,11 @@ function cmdlineMenu() {
writeConfigKey "cmdline.mac1" "${MAC1}" "${USER_CONFIG_FILE}" writeConfigKey "cmdline.mac1" "${MAC1}" "${USER_CONFIG_FILE}"
writeConfigKey "cmdline.netif_num" "1" "${USER_CONFIG_FILE}" writeConfigKey "cmdline.netif_num" "1" "${USER_CONFIG_FILE}"
fi fi
/etc/init.d/S30arpl-mac restart 2>&1 | dialog --backtitle "`backtitle`" \
--title "User cmdline" --progressbox "Changing mac" 20 70
/etc/init.d/S41dhcpcd restart 2>&1 | dialog --backtitle "`backtitle`" \
--title "User cmdline" --progressbox "Renewing IP" 20 70
IP=`ip route get 1.1.1.1 2>/dev/null | awk '{print$7}'`
;; ;;
s) s)
ITEMS="" ITEMS=""