Merge pull request #231 from pocopico/0.9.4.0

Added serials for new models
This commit is contained in:
pocopico
2023-01-17 10:43:44 +02:00
committed by GitHub
3 changed files with 79 additions and 15 deletions

View File

@ -499,9 +499,10 @@ function recho() {
function getvars() {
sudo ln -s /lib /lib64
ln -s /lib /lib64
tcrppart="$(mount | grep -i optional | grep cde | awk -F / '{print $3}' | uniq | cut -c 1-3)3"
tcrpdisk="$(mount | grep -i optional | grep cde | awk -F / '{print $3}' | uniq | cut -c 1-3)"
local_cache="/mnt/${tcrppart}/auxfiles"
GETTIME=$(curl -v --silent https://google.com/ 2>&1 | grep Date | sed -e 's/< Date: //')
INTERNETDATE=$(date +"%d%m%Y" -d "$GETTIME")
@ -521,6 +522,9 @@ function getvars() {
FILENAME="${OS_ID}.pat"
mount ${tcrppart}
mount ${tcrpdisk}1
mount ${tcrpdisk}2
#wecho "tcrppart : $tcrppart local_cache : $local_cache INTERNETDATE : $INTERNETDATE \ LOCALDATE : $LOCALDATE
#OS_ID : $OS_ID PAT_URL : $PAT_URL PAT_SHA : $PAT_SHA \
@ -902,12 +906,24 @@ function patchramdisk() {
fi
[ -f ${TEMPPAT}/initrd-dsm ] && wecho "Patched ramdisk created $(ls -l ${TEMPPAT}/initrd-dsm)"
wecho "Copying file to ${tcrppart}"
wecho "Copying files to ${tcrppart}"
cp -f $HOMEPATH/custom.gz /mnt/${tcrppart}/
cp -f ${TEMPPAT}/zImage-dsm /mnt/${tcrppart}/
cp -f ${TEMPPAT}/initrd-dsm /mnt/${tcrppart}/
cp -f ${TEMPPAT}/zImage /mnt/${tcrppart}1/
cp -f ${TEMPPAT}/rd.gz /mnt/${tcrppart}1/
cp -f $HOMEPATH/custom.gz /mnt/${tcrppart}1/
cp -f ${TEMPPAT}/zImage /mnt/${tcrppart}2/
cp -f ${TEMPPAT}/rd.gz /mnt/${tcrppart}2/
rm -rf $HOMEPATH/html/$patfile
rm -rf $HOMEPATH/temppat
}
json_get_keys() {

View File

@ -2,12 +2,12 @@
#
# Author :
# Date : 230108
# Version : 0.9.4.1
# Version : 0.9.4.2
#
#
# User Variables :
rploaderver="0.9.4.1"
rploaderver="0.9.4.2"
build="main"
redpillmake="prod"
@ -89,6 +89,7 @@ function history() {
0.9.3.0 Changed set root entry to search for FS UUID
0.9.4.0 Added experimental DS923+ model, added new extensions handler functions
0.9.4.1 Fixed missing serian and mac if user has not taken that into account.
0.9.4.2 Added serial numbers prefixes for DS923+ and DS1522xs+
--------------------------------------------------------------------------------------
EOF
@ -489,7 +490,7 @@ function syntaxcheck() {
serialgen)
echo "Syntax error, You have to specify one of the existing models"
echo "DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xs+ FS6400 DVA3219 DVA3221 DS1621+ DS923+ DVA1622 DS2422+ RS4021xs+"
echo "DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xs+ FS6400 DVA3219 DVA3221 DS1621+ DS923+ DVA1622 DS2422+ RS4021xs+ DS923+ DS1522xs+"
;;
patchdtc)
@ -2201,7 +2202,7 @@ function serialgen() {
[ "$2" == "realmac" ] && let keepmac=1 || let keepmac=0
if [ "$1" = "DS3615xs" ] || [ "$1" = "DS3617xs" ] || [ "$1" = "DS916+" ] || [ "$1" = "DS918+" ] || [ "$1" = "DS920+" ] || [ "$1" = "DS3622xs+" ] || [ "$1" = "FS6400" ] || [ "$1" = "DVA3219" ] || [ "$1" = "DVA3221" ] || [ "$1" = "DS1621+" ] || [ "$1" = "DS923+" ] || [ "$1" = "DVA1622" ] || [ "$1" = "DS2422+" ] || [ "$1" = "RS4021xs+" ]; then
if [ "$1" = "DS3615xs" ] || [ "$1" = "DS3617xs" ] || [ "$1" = "DS916+" ] || [ "$1" = "DS918+" ] || [ "$1" = "DS920+" ] || [ "$1" = "DS3622xs+" ] || [ "$1" = "FS6400" ] || [ "$1" = "DVA3219" ] || [ "$1" = "DVA3221" ] || [ "$1" = "DS1621+" ] || [ "$1" = "DS923+" ] || [ "$1" = "DVA1622" ] || [ "$1" = "DS2422+" ] || [ "$1" = "RS4021xs+" ] || [ "$1" = "DS1522xs+" ] || [ "$1" = "DS923+" ]; then
serial="$(generateSerial $1)"
mac="$(generateMacAddress $1)"
realmac=$(ifconfig eth0 | head -1 | awk '{print $NF}')
@ -2235,7 +2236,7 @@ function serialgen() {
fi
else
echo "Error : $1 is not an available model for serial number generation. "
echo "Available Models : DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xs+ FS6400 DVA3219 DVA3221 DS1621+ DS923+ DVA1622 DS2422+ RS4021xs+"
echo "Available Models : DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xs+ FS6400 DVA3219 DVA3221 DS1621+ DS923+ DVA1622 DS2422+ RS4021xs+ DS923+ DS1522xs+"
fi
}
@ -2296,9 +2297,18 @@ function beginArray() {
serialstart="2080"
;;
RS4021xs+)
permanent="SQR"
serialstart="2030 2040 20C0 2150"
permanent="T2R"
serialstart="2250"
;;
DS923+)
permanent="TQR"
serialstart="2270"
;;
DS1522xs+)
permanent="TRR"
serialstart="2270"
;;
esac
}
@ -2330,8 +2340,14 @@ function toupper() {
}
function generateMacAddress() {
#toupper "Mac Address: 00:11:32:$(randomhex):$(randomhex):$(randomhex)"
printf '00:11:32:%02X:%02X:%02X' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256))
if [ "$1" = "DS923+" ] || [ "$1" = "DS1522xs+" ] || [ "$1" = "RS4021xs+" ]; then
# DS1522xs+ and DS923+ Mac starts with 90:09:d0
printf '90:09:d0:%02X:%02X:%02X' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256))
else
printf '00:11:32:%02X:%02X:%02X' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256))
fi
}
@ -2383,6 +2399,12 @@ function generateSerial() {
RS4021xs+)
serialnum=$(toupper "$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter))
;;
DS923+)
serialnum=$(toupper "$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter))
;;
DS1522xs+)
serialnum=$(toupper "$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter))
;;
esac
echo $serialnum
@ -2649,7 +2671,7 @@ mountshare, version, monitor, bringfriend, downloadupgradepat, help
- serialgen <synomodel> <option> :
Generates a serial number and mac address for the following platforms
DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xs+ FS6400 DVA3219 DVA3221 DS1621+ DS923+ DVA1622 DS2422+ RS4021xs+
DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xs+ FS6400 DVA3219 DVA3221 DS1621+ DS923+ DVA1622 DS2422+ RS4021xs+ DS923+ DS1522xs+
Valid Options : realmac , keeps the real mac of interface eth0

View File

@ -49,6 +49,18 @@ function beginArray() {
permanent="SJR"
serialstart="2030 2040 20C0 2150"
;;
RS4021xs+)
permanent="T2R"
serialstart="2250"
;;
DS1522xs+)
permanent="TRR"
serialstart="2270"
;;
DS923+)
permanent="TQR"
serialstart="2270"
;;
esac
@ -83,7 +95,12 @@ function toupper() {
function generateMacAddress() {
#toupper "Mac Address: 00:11:32:$(randomhex):$(randomhex):$(randomhex)"
printf '00:11:32:%02X:%02X:%02X' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256))
if [ "$1" = "DS923+" ] || [ "$1" = "DS1522xs+" ] || [ "$1" = "RS4021xs+" ]; then
# DS1522xs+ and DS923+ Mac starts with 90:09:d0
printf '90:09:d0:%02X:%02X:%02X' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256))
else
printf '00:11:32:%02X:%02X:%02X' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256))
fi
}
@ -126,6 +143,15 @@ function generateSerial() {
DVA1622)
serialnum=$(toupper "$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter))
;;
RS4021xs+)
serialnum=$(toupper "$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter))
;;
DS923+)
serialnum=$(toupper "$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter))
;;
DS1522xs+)
serialnum=$(toupper "$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(generateRandomLetter)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomValue)$(generateRandomLetter))
;;
esac
echo $serialnum
@ -142,7 +168,7 @@ Usage: ${0} <platform>
Available platforms :
----------------------------------------------------------------------------------------
DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xsp FS6400 DVA3219 DVA3221 DS1621+ DVA1622
DS3615xs DS3617xs DS916+ DS918+ DS920+ DS3622xsp FS6400 DVA3219 DVA3221 DS1621+ DVA1622 RS4021xs+ DS923+ SD1522xs+
e.g. $(basename ${0}) DS3615xs
----------------------------------------------------------------------------------------
@ -153,8 +179,8 @@ EOF
if [ -z "$1" ]; then
showhelp
else
if [ "$1" = "DS3615xs" ] || [ "$1" = "DS3617xs" ] || [ "$1" = "DS916+" ] || [ "$1" = "DS918+" ] || [ "$1" = "DS920+" ] || [ "$1" = "DS3622xsp" ] || [ "$1" = "FS6400" ] || [ "$1" = "DVA3219" ] || [ "$1" = "DVA3221" ] || [ "$1" = "DS1621+" ] || [ "$1" = "DVA1622" ]; then
echo "Generating a random mac address : " $(generateMacAddress)
if [ "$1" = "DS3615xs" ] || [ "$1" = "DS3617xs" ] || [ "$1" = "DS916+" ] || [ "$1" = "DS918+" ] || [ "$1" = "DS920+" ] || [ "$1" = "DS3622xsp" ] || [ "$1" = "FS6400" ] || [ "$1" = "DVA3219" ] || [ "$1" = "DVA3221" ] || [ "$1" = "DS1621+" ] || [ "$1" = "DVA1622" ] || [ "$1" = "RS4021xs+" ] || [ "$1" = "DS923+" ] || [ "$1" = "DS1522xs+" ]; then
echo "Generating a random mac address : " $(generateMacAddress $1)
echo "Generating a Serial Number for Model $1: " $(generateSerial $1)
else
echo "Error : $1 is not an available model for serial number generation. "