Skip to content

Commit

Permalink
ver="4.2.1-r01"
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterSuh-Q3 committed Mar 21, 2023
1 parent 3e81da6 commit 815366c
Showing 1 changed file with 94 additions and 12 deletions.
106 changes: 94 additions & 12 deletions cpuinfo/src/cpuinfo.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh
ver="4.0.0-r01"
# Updated 2023.03.05 - By FOXBI
# htttps://github.com/foxbi/ch_cpuinfo
ver="4.2.1-r01"
# ==============================================================================
# Location Check
# ==============================================================================
Expand Down Expand Up @@ -86,17 +88,31 @@ PREPARE_FN () {
tar -cf $BKUP_DIR/$TIME/admin_center.tar admin_center.js*
cd $MWORK_DIR
tar -cf $BKUP_DIR/$TIME/mobile.tar mobile.js*
if [ -f "$SWORK_DIR/System.js" ]
then
cd $SWORK_DIR
tar -cf $BKUP_DIR/$TIME/System.tar System.js*
cp -Rf $SWORK_DIR/System.js $BKUP_DIR/
fi
fi
if [ "$MA_VER" -eq "6" ] && [ "$MI_VER" -ge "2" ]
then
mv $WORK_DIR/admin_center.js.gz $BKUP_DIR/
mv $MWORK_DIR/mobile.js.gz $BKUP_DIR/
if [ -f "$SWORK_DIR/System.js" ]
then
cp -Rf $SWORK_DIR/System.js $BKUP_DIR/
fi
cd $BKUP_DIR/
gzip -df $BKUP_DIR/admin_center.js.gz
gzip -df $BKUP_DIR/mobile.js.gz
gzip -df $BKUP_DIR/mobile.js.gz
else
cp -Rf $WORK_DIR/admin_center.js $BKUP_DIR/
cp -Rf $MWORK_DIR/mobile.js $BKUP_DIR/
if [ -f "$SWORK_DIR/System.js" ]
then
cp -Rf $SWORK_DIR/System.js $BKUP_DIR/
fi
fi
else
COMMENT08_FN
Expand All @@ -123,7 +139,18 @@ GATHER_FN () {
fi
if [ "$cpu_vendor" == "AMD" ]
then
pro_cnt=`cat /proc/cpuinfo | grep model | grep name | sort -u | awk -F: '{print $2}' | sed "s/^\s*AMD//g" | sed "s/^\s//g" | head -1 | grep -wi "PRO" | wc -l`
if [ "$pro_cnt" -gt 0 ]
then
pro_chk="-wi PRO"
else
pro_chk="-v PRO"
fi
cpu_series=`cat /proc/cpuinfo | grep model | grep name | sort -u | awk -F: '{print $2}' | sed "s/^\s*AMD//g" | sed "s/^\s//g" | head -1 | awk '{ for(i = NF; i > 1; i--) if ($i ~ /^[0-9]/) { for(j=i;j<=NF;j++)printf("%s ", $j);print("\n");break; }}' | sed "s/ *$//g"`
if [ -z "$cpu_series" ]
then
cpu_series=`cat /proc/cpuinfo | grep model | grep name | sort -u | awk -F: '{print $2}' | sed "s/^\s*AMD//g" | sed "s/^\s//g" | head -1 | awk '{ for(i = NF; i >= 1; i--) if ($i ~ ".*-.*") { print $i }}' | sed "s/ *$//g"`
fi
cpu_family=`cat /proc/cpuinfo | grep model | grep name | sort -u | awk -F: '{print $2}' | sed "s/^\s*AMD//g" | sed "s/^\s//g" | head -1 | awk -F"$cpu_series" '{print $1}' | sed "s/ *$//g"`
elif [ "$cpu_vendor" == "Intel" ]
then
Expand Down Expand Up @@ -183,12 +210,20 @@ GATHER_FN () {
then
cpu_search=`echo "$cpu_series" | awk '{print $1" "$2}'`
gen_url=`curl --silent -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" http://stackoverflow.com/questions/28760694/how-to-use-curl-to-get-a-get-request-exactly-same-as-using-chrome \
https://www.amd.com/en/products/specifications/processors | grep -wi "$cpu_search" | awk -F"views-field" '{print $1}' | awk -F"entity-" '{print $2}'`
https://www.amd.com/en/products/specifications/processors | grep -wi "$cpu_search" | grep $pro_chk | awk -F"views-field" '{print $1}' | awk -F"entity-" '{print $2}'`
if [ -z "$gen_url" ]
then
chg_series=`echo $cpu_series | awk '{print $1}'`
gen_url=`curl --silent -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" http://stackoverflow.com/questions/28760694/how-to-use-curl-to-get-a-get-request-exactly-same-as-using-chrome \
https://www.amd.com/en/products/specifications/processors | grep -wi "$chg_series" | awk -F"views-field" '{print $1}' | awk -F"entity-" '{print $2}'`
https://www.amd.com/en/products/specifications/processors | grep -wi "$chg_series" | grep $pro_chk | awk -F"views-field" '{print $1}' | awk -F"entity-" '{print $2}'`
fi
if [ -z "$gen_url" ]
then
cpu_series=`cat /proc/cpuinfo | grep model | grep name | sort -u | awk -F: '{print $2}' | sed "s/^\s*AMD//g" | sed "s/^\s//g" | head -1 | awk '{ for(i = NF; i >= 1; i--) if ($i ~ ".*-.*") { print $i }}' | sed "s/ *$//g"`
cpu_family=`cat /proc/cpuinfo | grep model | grep name | sort -u | awk -F: '{print $2}' | sed "s/^\s*AMD//g" | sed "s/^\s//g" | head -1 | awk -F"$cpu_series" '{print $1}' | sed "s/ *$//g"`
chg_series=`echo $cpu_series | awk '{print $1}'`
gen_url=`curl --silent -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" http://stackoverflow.com/questions/28760694/how-to-use-curl-to-get-a-get-request-exactly-same-as-using-chrome \
https://www.amd.com/en/products/specifications/processors | grep -wi "$chg_series" | grep $pro_chk | awk -F"views-field" '{print $1}' | awk -F"entity-" '{print $2}'`
fi
cpu_gen=`curl --silent -H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" http://stackoverflow.com/questions/28760694/how-to-use-curl-to-get-a-get-request-exactly-same-as-using-chrome \
https://www.amd.com/en/product/$gen_url | egrep -A 2 -w ">Former Codename<|>Architecture<" | grep "field__item" | sed "s/&quot;/\"/g" | awk -F\"\>\" '{print $2}' | awk -F\" '{print $1}' | tr "\n" "| " | awk -F\| '{if($2=="") {print $1} else {print $1" | " $2}}'`
Expand Down Expand Up @@ -248,13 +283,22 @@ PERFORM_FN () {
then
cpu_info=`echo "${dt}.cpu_vendor=\"${cpu_vendor}\",${dt}.cpu_family=\"${cpu_family}\",${dt}.cpu_series=\"${cpu_series}\",${dt}.cpu_cores=\"${cpu_cores}\",${dt}.cpu_detail=\"${cpu_detail}\","`
sed -i "s/Ext.isDefined(${dt}.cpu_vendor/${cpu_info}Ext.isDefined(${dt}.cpu_vendor/g" $BKUP_DIR/admin_center.js
if [ -f "$BKUP_DIR/System.js" ]
then
cpu_info_s=`echo ${cpu_info} | sed "s/${dt}.cpu/${st}.cpu/g"`
sed -i "s/Ext.isDefined(${st}.cpu_vendor/${cpu_info_s}Ext.isDefined(${st}.cpu_vendor/g" $BKUP_DIR/System.js
fi
else
cpu_info=`echo "${dt}.cpu_vendor=\"${cpu_vendor}\";${dt}.cpu_family=\"${cpu_family}\";${dt}.cpu_series=\"${cpu_series}\";${dt}.cpu_cores=\"${cpu_cores}\";${dt}.cpu_detail=\"${cpu_detail}\";"`
sed -i "s/if(Ext.isDefined(${dt}.cpu_vendor/${cpu_info}if(Ext.isDefined(${dt}.cpu_vendor/g" $BKUP_DIR/admin_center.js
fi
sed -i "s/${dt}.cpu_series)])/${dt}.cpu_series,${dt}.cpu_detail)])/g" $BKUP_DIR/admin_center.js
sed -i "s/{2}\",${dt}.cpu_vendor/{2} {3}\",${dt}.cpu_vendor/g" $BKUP_DIR/admin_center.js

if [ -f "$BKUP_DIR/System.js" ]
then
sed -i "s/${st}.cpu_series)])/${st}.cpu_series,${st}.cpu_detail)])/g" $BKUP_DIR/System.js
sed -i "s/{2}\",${st}.cpu_vendor/{2} {3}\",${st}.cpu_vendor/g" $BKUP_DIR/System.js
fi
cpu_info_m=`echo "{name: \"cpu_series\",renderer: function(value){var cpu_vendor=\"${cpu_vendor}\";var cpu_family=\"${cpu_family}\";var cpu_series=\"${cpu_series}\";var cpu_cores=\"${cpu_cores}\";return Ext.String.format('{0} {1} {2} [ {3} ]', cpu_vendor, cpu_family, cpu_series, cpu_cores);},label: _T(\"status\", \"cpu_model_name\")},"`
sed -i "s/\"ds_model\")},/\"ds_model\")},${cpu_info_m}/g" $BKUP_DIR/mobile.js
else
Expand All @@ -276,10 +320,15 @@ APPLY_FN () {
then
cp -Rf $BKUP_DIR/admin_center.js $WORK_DIR/
cp -Rf $BKUP_DIR/mobile.js $MWORK_DIR/
if [ -f "$BKUP_DIR/System.js" ]
then
cp -Rf $BKUP_DIR/System.js $SWORK_DIR/
rm -rf $BKUP_DIR/System.js
fi
if [ "$MA_VER" -eq "6" ] && [ "$MI_VER" -lt "2" ]
then
rm -rf $BKUP_DIR/admin_center.js
rm -rf $BKUP_DIR/mobile.js
rm -rf $BKUP_DIR/mobile.js
else
gzip -f $BKUP_DIR/admin_center.js
gzip -f $BKUP_DIR/mobile.js
Expand All @@ -301,6 +350,11 @@ RECOVER_FN () {
cd $MWORK_DIR
tar -xf $BKUP_DIR/$TIME/mobile.tar
fi
if [ -f "$BKUP_DIR/$TIME/System.tar" ]
then
cd $SWORK_DIR
tar -xf $BKUP_DIR/$TIME/System.tar
fi
if [ "$re_check" == "y" ]
then
if [ "$LC_CHK" == "CUSTOMLANG" ]
Expand Down Expand Up @@ -329,9 +383,13 @@ RERUN_FN () {
then
if [ "$MA_VER" -ge "7" ]
then
info_cnt=`cat $WORK_DIR/admin_center.js | egrep "t.model\]\),Ext.isDefined\(t.cpu_vendor" | wc -l`
info_cnt=`cat $WORK_DIR/admin_center.js | egrep "${dt}.model\]\),Ext.isDefined\(${dt}.cpu_vendor" | wc -l`
if [ -f "$BKUP_DIR/System.js" ]
then
info_cnt_s=`cat $WORK_DIR/admin_center.js | egrep "${st}.model\]\),Ext.isDefined\(${st}.cpu_vendor" | wc -l`
fi
else
info_cnt=`cat $WORK_DIR/admin_center.js | egrep ".model\]\);if\(Ext.isDefined|.model\]\)\}if\(Ext.isDefined" | wc -l`
info_cnt=`cat $WORK_DIR/admin_center.js | egrep ".model\]\);if\(Ext.isDefined|.model\]\)\}if\(Ext.isDefined" | wc -l`
fi
info_cnt_m=`cat $MWORK_DIR/mobile.js | grep "ds_model\")},{name:\"ram_size" | wc -l`
if [ "$info_cnt" -eq "0" ] && [ "$info_cnt_m" -eq "0" ]
Expand All @@ -346,6 +404,7 @@ RERUN_FN () {
if [ "$MA_VER" -ge "7" ]
then
cpu_info="${dt}.cpu_vendor=\\\"${cpu_vendor}\\\",${dt}.cpu_family=\\\"${cpu_family}\\\",${dt}.cpu_series=\\\"${cpu_series}\\\",${dt}.cpu_cores=\\\"${cpu_cores}\\\",${dt}.cpu_detail=\\\"${cpu_detail}\\\","
cpu_info_s="${st}.cpu_vendor=\\\"${cpu_vendor}\\\",${st}.cpu_family=\\\"${cpu_family}\\\",${st}.cpu_series=\\\"${cpu_series}\\\",${st}.cpu_cores=\\\"${cpu_cores}\\\",${st}.cpu_detail=\\\"${cpu_detail}\\\","
else
cpu_info="${dt}.cpu_vendor=\\\"${cpu_vendor}\\\";${dt}.cpu_family=\\\"${cpu_family}\\\";${dt}.cpu_series=\\\"${cpu_series}\\\";${dt}.cpu_cores=\\\"${cpu_cores}\\\";${dt}.cpu_detail=\\\"${cpu_detail}\\\";"
fi
Expand Down Expand Up @@ -501,6 +560,15 @@ EXEC_FN () {
if [ -d $WORK_DIR ]
then
Y_N="y"
if [ "$LC_CHK" == "CUSTOMLANG" ]
then
READ_YN "$MSGECHO04 "
elif [ "$LC_CHK" == "Seoul" ]
then
READ_YN "자동으로 실행합니다. n 선택시 대화형모드로 진행합니다. (취소하려면 q) [y/n] : "
else
READ_YN "Auto Excute, If you select n, proceed interactively (Cancel : q) [y/n] : "
fi
if [ "$Y_N" == "y" ]
then
mkdir -p $BKUP_DIR/$TIME
Expand Down Expand Up @@ -680,12 +748,24 @@ COMMENT08_FN () {
COMMENT09_FN () {
if [ "$LC_CHK" == "CUSTOMLANG" ]
then
echo -e "$MSGECHO13"
if [ -f "$SWORK_DIR/System.js" ]
then
echo -e "$MSGECHO13"
fi
echo -e "$MSGECHO13"
elif [ "$LC_CHK" == "Seoul" ]
then
echo -e "작업이완료 되었습니다!! 반영에는 약 1~2분 소요되며, \n(F5로 DSM 페이지 새로고침 후 또는 로그아웃/로그인 후 정보를 확인바랍니다.)"
if [ -f "$SWORK_DIR/System.js" ]
then
echo -e "Surveillance Studio를 사용하는 경우 Surveillance Studio 시스템 정보에도 반영됩니다."
fi
echo -e "작업이완료 되었습니다!! 반영에는 약 1~2분 소요되며, \n(F5로 DSM 페이지 새로고침 후 또는 로그아웃/로그인 후 정보를 확인바랍니다."
else
echo -e "The operation is complete!! It takes about 1-2 minutes to reflect, \n(Please refresh the DSM page with F5 or after logout/login and check the information.)"
if [ -f "$SWORK_DIR/System.js" ]
then
echo -e "If you use Surveillance Studio, it also applies to Surveillance Studio System Information."
fi
echo -e "The operation is complete!! It takes about 1-2 minutes to apply, \n(Please refresh the DSM page with F5 or after logout/login and check the information.)"
fi
exit 0
}
Expand All @@ -708,6 +788,7 @@ COMMENT10_FN () {
# ==============================================================================
clear
WORK_DIR="/usr/syno/synoman/webman/modules/AdminCenter"
SWORK_DIR="/var/packages/SurveillanceStation/target/ui/modules/System"
MWORK_DIR="/usr/syno/synoman/mobile/ui"
BKUP_DIR="/root/Xpenology_backup"
VER_DIR="/etc.default"
Expand Down Expand Up @@ -783,6 +864,7 @@ then
if [ "$MA_VER" -ge "7" ]
then
dt=t
st=e
else
if [ "$BL_NUM" -ge "24922" ]
then
Expand All @@ -802,7 +884,7 @@ fi

GATHER_FN

cpu_cores=`echo ${cpu_cores} | sed 's/\\\//g'`
cpu_cores=`echo ${cpu_cores}"-"${cpu_gen} | sed 's/\\\//g'`

if [ "$LC_CHK" == "CUSTOMLANG" ]
then
Expand Down

0 comments on commit 815366c

Please sign in to comment.