kacy Posted September 17, 2018 Share #26 Posted September 17, 2018 Thank you, FOXBI! Can you publish last version shell script? 1 Quote Link to comment Share on other sites More sharing options...
FOXBI Posted September 17, 2018 Author Share #27 Posted September 17, 2018 1 hour ago, kacy said: Thank you, FOXBI! Can you publish last version shell script? I am not a professional developer I am a bit embarrassed every time I release the source ,, Please see below. Spoiler #!/bin/bash # ver 4.0 2018.09.13 Made by FOXBI # ver 3.0 2018.08.24 Made by FOXBI # Ver 1.5 2018.08.23 Made by FOXBI # Ver 1.1 2018.08.22 Made by FOXBI # Ver 1.0 2018.08.17 Made by FOXBI ver="4.0" # ============================================================================== # Y or N Function # ============================================================================== READ_YN () { # $1:question $2:default read -n1 -p "$1" Y_N case "$Y_N" in y) Y_N="y" echo -e "\n" ;; n) Y_N="n" echo -e "\n" ;; q) echo -e "\n" exit 0 ;; *) echo -e "\n" ;; esac } # ============================================================================== # Process Function # ============================================================================== PREPARE_FN () { if [ -f "$WORK_DIR/admin_center.js" ] && [ -f "$MWORK_DIR/mobile.js" ] then if [ "$direct_job" == "y" ] then echo "warning!! Work directly on the original file without backup.\n" else cd $WORK_DIR tar -cf $BKUP_DIR/$TIME/admin_center.tar admin_center.js* cd $MWORK_DIR tar -cf $BKUP_DIR/$TIME/mobile.tar mobile.js* 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/ cd $BKUP_DIR/ gzip -df $BKUP_DIR/admin_center.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/ fi else COMMENT08_FN fi } GATHER_FN () { DMI_CHK=`dmidecode | grep 'SMBIOS' | egrep 'NO|sorry' | wc -l` if [ "$DMI_CHK" -gt "0" ] then cpu_vendor=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $4}'` if [ "$cpu_vendor" == "AMD" ] then cpu_family=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk -F "$cpu_vendor " '{ print $2 }' | awk -F "Processor" '{ print $1 }'` cpu_series="" else cpu_family=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $5}'` cpu_series=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{ if (index($7,"@")!=0) { print $6 } else { print $6" "$7 } }'` fi else cpu_vendor=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $2}'` if [ "$cpu_vendor" == "AMD" ] then cpu_family=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk -F "$cpu_vendor " '{ print $2 }' | awk -F "Processor" '{ print $1 }'` cpu_series="" else cpu_family=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $3}'` cpu_series=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{ if (index($5,"@")!=0) { print $4 } else { print $4" "$5 } }'` fi fi cpu_cores=`cat /proc/cpuinfo | grep processor| wc -l` } PERFORM_FN () { if [ -f "$BKUP_DIR/admin_center.js" ] && [ -f "$BKUP_DIR/mobile.js" ] then if [ "$MA_VER" -ge "6" ] then cpu_info=`echo "f.cpu_vendor=\"${cpu_vendor}\";f.cpu_family=\"${cpu_family}\";f.cpu_series=\"${cpu_series}\";f.cpu_cores=\"${cpu_cores}\";"` sed -i "s/f.model]);/f.model]);${cpu_info}/g" $BKUP_DIR/admin_center.js 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}Core)', 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 if [ "$MI_VER" -gt "0" ] then cpu_info=`echo "b.cpu_vendor=\"${cpu_vendor}\";b.cpu_family=\"${cpu_family}\";b.cpu_series=\"${cpu_series}\";b.cpu_cores=\"${cpu_cores}\";"` else cpu_info=`echo "b.cpu_vendor=\"${cpu_vendor}\";b.cpu_family=\"${cpu_family} ${cpu_series}\";b.cpu_cores=\"${cpu_cores}\";"` fi sed -i "s/b.model]);/b.model]);${cpu_info}/g" $BKUP_DIR/admin_center.js fi else COMMENT08_FN fi } APPLY_FN () { if [ -f "$BKUP_DIR/admin_center.js" ] && [ -f "$BKUP_DIR/mobile.js" ] then cp -Rf $BKUP_DIR/admin_center.js $WORK_DIR/ cp -Rf $BKUP_DIR/mobile.js $MWORK_DIR/ if [ "$MA_VER" -eq "6" ] && [ "$MI_VER" -ge "2" ] then gzip -f $BKUP_DIR/admin_center.js gzip -f $BKUP_DIR/mobile.js mv $BKUP_DIR/admin_center.js.gz $WORK_DIR/ mv $BKUP_DIR/mobile.js.gz $MWORK_DIR/ else rm -rf $BKUP_DIR/admin_center.js rm -rf $BKUP_DIR/mobile.js fi else COMMENT08_FN fi } RECOVER_FN () { if [ -d "$BKUP_DIR/$TIME" ] then cd $WORK_DIR tar -xf $BKUP_DIR/$TIME/admin_center.tar if [ -f "$BKUP_DIR/$TIME/mobile.tar" ] then cd $MWORK_DIR tar -xf $BKUP_DIR/$TIME/mobile.tar fi if [ "$re_check" == "y" ] then echo -e "Restore to source and continue.\n" else COMMENT09_FN fi else COMMENT08_FN fi } RERUN_FN () { if [ "$1" == "redo" ] then ls -l $BKUP_DIR/ | grep ^d | grep -v "$BL_CHK" | awk '{print "rm -rf '$BKUP_DIR'/"$9}' | sh GATHER_FN if [ -f "$WORK_DIR/admin_center.js" ] && [ -f "$MWORK_DIR/mobile.js" ] then info_cnt=`cat $WORK_DIR/admin_center.js | grep ".model]);if(Ext.isDefined" | wc -l` 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" ] then if [ "$MA_VER" -ge "6" ] then cpu_info="f.cpu_vendor=\\\"${cpu_vendor}\\\";f.cpu_family=\\\"${cpu_family}\\\";f.cpu_series=\\\"${cpu_series}\\\";f.cpu_cores=\\\"${cpu_cores}\\\";" sed -i "s/${cpu_info}//g" $WORK_DIR/admin_center.js cpu_info_m="{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}Core)', cpu_vendor, cpu_family, cpu_series, cpu_cores);},label: _T(\\\"status\\\", \\\"cpu_model_name\\\")}," sed -i "s/${cpu_info_m}//g" $MWORK_DIR/mobile.js if [ "$MI_VER" -ge "2" ] then cp -Rf $WORK_DIR/admin_center.js $WORK_DIR/admin_center.js.1 cp -Rf $MWORK_DIR/mobile.js $MWORK_DIR/mobile.js.1 gzip -f $WORK_DIR/admin_center.js gzip -f $MWORK_DIR/mobile.js mv $WORK_DIR/admin_center.js.1 $WORK_DIR/admin_center.js mv $MWORK_DIR/mobile.js.1 $MWORK_DIR/mobile.js fi else if [ "$MI_VER" -gt "0" ] then cpu_info="b.cpu_vendor=\\\"${cpu_vendor}\\\";b.cpu_family=\\\"${cpu_family}\\\";b.cpu_series=\\\"${cpu_series}\\\";b.cpu_cores=\\\"${cpu_cores}\\\";" else cpu_info="b.cpu_vendor=\\\"${cpu_vendor}\\\";b.cpu_family=\\\"${cpu_family} ${cpu_series}\\\";b.cpu_cores=\\\"${cpu_cores}\\\";" fi sed -i "s/${cpu_info}//g" $WORK_DIR/admin_center.js fi fi else COMMENT08_FN fi fi } BLCHECK_FN () { bl_check=n if [ -d "$BKUP_DIR" ] then BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | wc -l` if [ "$BK_CNT" -gt "0" ] then BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | grep "$BL_CHK" | wc -l` if [ "$BK_CNT" -gt "0" ] then TIME=`ls -l $BKUP_DIR/ | grep ^d | grep "$BL_CHK" | awk '{print $9}' | head -1` BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | grep -v "$BL_CHK" | wc -l` if [ "$BK_CNT" -gt "0" ] then BLSUB_FN "$1" else if [ "$re_check" == "n" ] then if [ "$1" == "run" ] then COMMENT03_FN fi COMMENT05_FN else STIME=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1` BLSUB_FN "redo" fi fi else if [ "$1" == "restore" ] then COMMENT07_FN fi BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | grep -v "$BL_CHK" | wc -l` if [ "$BK_CNT" -gt "0" ] then BL_COM=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1 | awk -F_ '{print $2}'` BL_CNT=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1 | awk -F_ '{print $2}' | wc -l` if [ "$BL_COM" == "" ] then if [ "$BL_CNT" -gt "0" ] then BLSUB_FN "$1" bl_check=y else COMMENT06_FN fi else TIME=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1` if [ "$BL_CHK" == "$BL_COM" ] then if [ "$1" == "run" ] then COMMENT03_FN else COMMENT05_FN bl_check=n fi else if [ "$BL_CHK" -gt "$BL_COM" ] then BLSUB_FN "$1" bl_check=y else COMMENT06_FN fi fi fi else COMMENT06_FN fi fi else CASE_FN "$1" fi else CASE_FN "$1" fi } BLSUB_FN () { TIME=`echo "$STIME"` if [ "$1" == "run" ] then RERUN_FN "redo" else RERUN_FN "$1" fi COMMENT05_FN } CASE_FN () { case "$1" in run) COMMENT05_FN ;; redo) COMMENT07_FN ;; restore) COMMENT07_FN ;; *) COMMENT06_FN ;; esac } EXEC_FN () { if [ -d $WORK_DIR ] then READ_YN "Auto Excute, If you select n, proceed interactively (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then mkdir -p $BKUP_DIR/$TIME if [ "$re_check" == "y" ] then if [ "$bl_check" == "y" ] then COMMENT04_FN else RECOVER_FN fi fi PREPARE_FN GATHER_FN PERFORM_FN APPLY_FN COMMENT09_FN elif [ "$Y_N" == "n" ] then READ_YN "Proceed with original file backup and preparation.. If you select n, Work directly on the original file. (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then mkdir -p $BKUP_DIR/$TIME if [ "$re_check" == "y" ] then if [ "$bl_check" == "y" ] then COMMENT04_FN else RECOVER_FN fi fi PREPARE_FN elif [ "$Y_N" == "n" ] then direct_job=y mkdir -p $BKUP_DIR PREPARE_FN else COMMENT10_FN fi READ_YN "CPU name, Core count and reflects it. If you select n, Resote original file (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then GATHER_FN PERFORM_FN APPLY_FN COMMENT09_FN elif [ "$Y_N" == "n" ] then if [ -d "$BKUP_DIR" ] then gzip $BKUP_DIR/admin_center.js gzip $BKUP_DIR/mobile.js mv $BKUP_DIR/admin_center.js.gz $WORK_DIR/ mv $BKUP_DIR/mobile.js.gz $MWORK_DIR/ COMMENT09_FN else COMMENT07_FN fi else COMMENT10_FN fi else COMMENT10_FN fi else COMMENT08_FN fi } COMMENT03_FN () { echo -e "There is a history of running the same version. Please run again select 2) redo .\n" exit 0 } COMMENT04_FN () { echo -e "Do not restore to source when installing a higher version. Contiue...\n" } COMMENT05_FN () { echo -e "You have verified and installed the previous version. Contiue...\n" } COMMENT06_FN () { echo -e "Problem and exit. Please run again after checking." exit 0 } COMMENT07_FN () { echo -e "No execution history. Please go back to the first run." exit 0 } COMMENT08_FN () { echo -e "The target file(location) does not exist. Please run again after checking." exit 0 } COMMENT09_FN () { 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.)" exit 0 } COMMENT10_FN () { echo -e "Only y / n / q can be input. Please proceed again." exit 0 } # ============================================================================== # Main Progress # ============================================================================== clear WORK_DIR="/usr/syno/synoman/webman/modules/AdminCenter" MWORK_DIR="/usr/syno/synoman/mobile/ui" BKUP_DIR="/root/Xpenology_backup" VER_DIR="/etc.default" echo "DSM CPU Information Change Tool ver. \033[0;31m"$ver"\033[00m - made by FOXBI\n" if [ -d "$VER_DIR" ] then VER_FIL="$VER_DIR/VERSION" else VER_FIL="/etc/VERSION" fi if [ -f "$VER_FIL" ] then MA_VER=`cat $VER_FIL | grep majorversion | awk -F \= '{print $2}' | sed 's/\"//g'` MI_VER=`cat $VER_FIL | grep minorversion | awk -F \= '{print $2}' | sed 's/\"//g'` BL_NUM=`cat $VER_FIL | grep buildnumber | awk -F \= '{print $2}' | sed 's/\"//g'` BL_FIX=`cat $VER_FIL | grep smallfixnumber | awk -F \= '{print $2}' | sed 's/\"//g'` else COMMENT08_FN fi BL_CHK=$BL_NUM$BL_FIX TIME=`date +%Y%m%d%H%M%S`"_"$BL_CHK STIME=`echo "$TIME"` if [ "$MA_VER" -gt "4" ] then if [ "$MA_VER" -eq "5" ] then MWORK_DIR="/usr/syno/synoman/webman/mapp" fi echo "Your version of DSM is \033[0;36mDSM \033[0;31m"$MA_VER"."$MI_VER"\033[0;32m continue...\n" else echo "DSM version less than 5 is not supported. End the process." exit 0 fi read -n1 -p "1) First run 2) Redo 3) Restore - Select Number : " inst_z case "$inst_z" in 1) inst_check=run echo -e "\n " ;; 2) inst_check=redo echo -e "\n " ;; 3) inst_check=restore echo -e "\n " ;; *) echo -e "\n" ;; esac if [ "$inst_check" == "redo" ] then READ_YN "Do you want to proceed again? Restore to original file backup and proceed.(Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then re_check=y BLCHECK_FN "$inst_check" inst_check=run EXEC_FN elif [ "$Y_N" == "n" ] then echo "Do not proceed with the redo." else COMMENT10_FN fi elif [ "$inst_check" == "restore" ] then READ_YN "Do you want to restore using the original backup file? (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then re_check=n BLCHECK_FN "$inst_check" RECOVER_FN elif [ "$Y_N" == "n" ] then echo "No restore was performed." else COMMENT10_FN fi elif [ "$inst_check" == "run" ] then re_check=n BLCHECK_FN "$inst_check" EXEC_FN else echo "Please select the correct number." fi 2 Quote Link to comment Share on other sites More sharing options...
kacy Posted September 17, 2018 Share #28 Posted September 17, 2018 Many thanks, FOXBI! The shell script works great! PS I recently had a trip to Korea. Korea is a beautiful country populated by wonderful people. 1 Quote Link to comment Share on other sites More sharing options...
Tibor Posted October 10, 2018 Share #29 Posted October 10, 2018 As the binary cannot be downloaded, I've made a cpu_info file by pasting your code into it. Copied to a temp folder on my XPEnology NAS. Then set executable attribute, but could only execute via sh command, then I get an error message. root@FORESTER:/volume1/tibor/Temp# sh cpu_info cpu_info: line 13: syntax error near unexpected token `$'in\r'' 'pu_info: line 13: ` case "$Y_N" in What did I wrong? I have DSM 6.2-23739 if that matters (don't think so). 1 Quote Link to comment Share on other sites More sharing options...
stefauresi Posted October 10, 2018 Share #30 Posted October 10, 2018 Hi, It's ok on DSM 6.2.1 for information Best regard Stéphane 1 Quote Link to comment Share on other sites More sharing options...
FOXBI Posted October 11, 2018 Author Share #31 Posted October 11, 2018 On 10/10/2018 at 1:25 PM, Tibor said: As the binary cannot be downloaded, I've made a cpu_info file by pasting your code into it. Copied to a temp folder on my XPEnology NAS. Then set executable attribute, but could only execute via sh command, then I get an error message. root@FORESTER:/volume1/tibor/Temp# sh cpu_info cpu_info: line 13: syntax error near unexpected token `$'in\r'' 'pu_info: line 13: ` case "$Y_N" in What did I wrong? I have DSM 6.2-23739 if that matters (don't think so). Hello, Why are not attachments being downloaded? Please contact the forum administrator. It may not be a problem in your shell environment or in the pasting process. Please try debugging with #sh -x cpu_info You can see at a glance where the error occurs. If you show me the results, I will look for problems together. Quote Link to comment Share on other sites More sharing options...
Tibor Posted October 11, 2018 Share #32 Posted October 11, 2018 On 10/11/2018 at 8:43 AM, FOXBI said: Hello, Why are not attachments being downloaded? Please contact the forum administrator. It may not be a problem in your shell environment or in the pasting process. Please try debugging with #sh -x cpu_info You can see at a glance where the error occurs. If you show me the results, I will look for problems together. As of the debug info root@FORESTER:/volume1/tibor/Temp# sh -x cpu_info + ver=$'4.0\r' cpu_info: line 13: syntax error near unexpected token `$'in\r'' 'pu_info: line 13: ` case "$Y_N" in I tried to download the binary again, this I could. Don't know why couldn't last time. I don't have luck with you script Executed like this and got that message: root@FORESTER:/volume1/tibor/Temp# ./ch_cpuinfo -ash: ./ch_cpuinfo: Text file busy What text filie might be busy? I'm in the middle of expanding my volume (running for a day now, but it's still at 36%), otherwise it's a new system, it's quite empty, no big packages running, etc. I have not expectations, you're kind already that took the time, made the script and publish it for so many people's delight 1 Quote Link to comment Share on other sites More sharing options...
FOXBI Posted October 12, 2018 Author Share #33 Posted October 12, 2018 19 hours ago, Tibor said: + ver=$'4.0\r' cpu_info: line 13: syntax error near unexpected token `$'in\r'' I think so happen problem, when you pasted shell source. original source not include \r Perhaps it seems that \r has been inserted in the line change during the pasting process. It is possible that some terminal programs may occur. Please compress the source created by notepad, upload & unzip it, and try to execute it gook luck Quote Link to comment Share on other sites More sharing options...
Tibor Posted October 18, 2018 Share #34 Posted October 18, 2018 Cool, it was probalby my mistake. I've downloaded again, set the permissions properly, executed and voila, it did work as it should 1 Quote Link to comment Share on other sites More sharing options...
Olegin Posted October 25, 2018 Share #35 Posted October 25, 2018 (edited) @FOXBI It seems, that don't work on 6.2.1 with 1.04b loader. UPD: After reboot - ok. Edited October 25, 2018 by Olegin 1 Quote Link to comment Share on other sites More sharing options...
Vileserver Posted October 26, 2018 Share #36 Posted October 26, 2018 On 9/16/2018 at 5:23 PM, FOXBI said: I am not a professional developer I am a bit embarrassed every time I release the source ,, Please see below. ch_cpuinfo Ver. 4.0 (Reveal hidden contents) #!/bin/bash # ver 4.0 2018.09.13 Made by FOXBI # ver 3.0 2018.08.24 Made by FOXBI # Ver 1.5 2018.08.23 Made by FOXBI # Ver 1.1 2018.08.22 Made by FOXBI # Ver 1.0 2018.08.17 Made by FOXBI ver="4.0" # ============================================================================== # Y or N Function # ============================================================================== READ_YN () { # $1:question $2:default read -n1 -p "$1" Y_N case "$Y_N" in y) Y_N="y" echo -e "\n" ;; n) Y_N="n" echo -e "\n" ;; q) echo -e "\n" exit 0 ;; *) echo -e "\n" ;; esac } # ============================================================================== # Process Function # ============================================================================== PREPARE_FN () { if [ -f "$WORK_DIR/admin_center.js" ] && [ -f "$MWORK_DIR/mobile.js" ] then if [ "$direct_job" == "y" ] then echo "warning!! Work directly on the original file without backup.\n" else cd $WORK_DIR tar -cf $BKUP_DIR/$TIME/admin_center.tar admin_center.js* cd $MWORK_DIR tar -cf $BKUP_DIR/$TIME/mobile.tar mobile.js* 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/ cd $BKUP_DIR/ gzip -df $BKUP_DIR/admin_center.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/ fi else COMMENT08_FN fi } GATHER_FN () { DMI_CHK=`dmidecode | grep 'SMBIOS' | egrep 'NO|sorry' | wc -l` if [ "$DMI_CHK" -gt "0" ] then cpu_vendor=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $4}'` if [ "$cpu_vendor" == "AMD" ] then cpu_family=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk -F "$cpu_vendor " '{ print $2 }' | awk -F "Processor" '{ print $1 }'` cpu_series="" else cpu_family=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $5}'` cpu_series=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{ if (index($7,"@")!=0) { print $6 } else { print $6" "$7 } }'` fi else cpu_vendor=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $2}'` if [ "$cpu_vendor" == "AMD" ] then cpu_family=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk -F "$cpu_vendor " '{ print $2 }' | awk -F "Processor" '{ print $1 }'` cpu_series="" else cpu_family=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $3}'` cpu_series=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{ if (index($5,"@")!=0) { print $4 } else { print $4" "$5 } }'` fi fi cpu_cores=`cat /proc/cpuinfo | grep processor| wc -l` } PERFORM_FN () { if [ -f "$BKUP_DIR/admin_center.js" ] && [ -f "$BKUP_DIR/mobile.js" ] then if [ "$MA_VER" -ge "6" ] then cpu_info=`echo "f.cpu_vendor=\"${cpu_vendor}\";f.cpu_family=\"${cpu_family}\";f.cpu_series=\"${cpu_series}\";f.cpu_cores=\"${cpu_cores}\";"` sed -i "s/f.model]);/f.model]);${cpu_info}/g" $BKUP_DIR/admin_center.js 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}Core)', 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 if [ "$MI_VER" -gt "0" ] then cpu_info=`echo "b.cpu_vendor=\"${cpu_vendor}\";b.cpu_family=\"${cpu_family}\";b.cpu_series=\"${cpu_series}\";b.cpu_cores=\"${cpu_cores}\";"` else cpu_info=`echo "b.cpu_vendor=\"${cpu_vendor}\";b.cpu_family=\"${cpu_family} ${cpu_series}\";b.cpu_cores=\"${cpu_cores}\";"` fi sed -i "s/b.model]);/b.model]);${cpu_info}/g" $BKUP_DIR/admin_center.js fi else COMMENT08_FN fi } APPLY_FN () { if [ -f "$BKUP_DIR/admin_center.js" ] && [ -f "$BKUP_DIR/mobile.js" ] then cp -Rf $BKUP_DIR/admin_center.js $WORK_DIR/ cp -Rf $BKUP_DIR/mobile.js $MWORK_DIR/ if [ "$MA_VER" -eq "6" ] && [ "$MI_VER" -ge "2" ] then gzip -f $BKUP_DIR/admin_center.js gzip -f $BKUP_DIR/mobile.js mv $BKUP_DIR/admin_center.js.gz $WORK_DIR/ mv $BKUP_DIR/mobile.js.gz $MWORK_DIR/ else rm -rf $BKUP_DIR/admin_center.js rm -rf $BKUP_DIR/mobile.js fi else COMMENT08_FN fi } RECOVER_FN () { if [ -d "$BKUP_DIR/$TIME" ] then cd $WORK_DIR tar -xf $BKUP_DIR/$TIME/admin_center.tar if [ -f "$BKUP_DIR/$TIME/mobile.tar" ] then cd $MWORK_DIR tar -xf $BKUP_DIR/$TIME/mobile.tar fi if [ "$re_check" == "y" ] then echo -e "Restore to source and continue.\n" else COMMENT09_FN fi else COMMENT08_FN fi } RERUN_FN () { if [ "$1" == "redo" ] then ls -l $BKUP_DIR/ | grep ^d | grep -v "$BL_CHK" | awk '{print "rm -rf '$BKUP_DIR'/"$9}' | sh GATHER_FN if [ -f "$WORK_DIR/admin_center.js" ] && [ -f "$MWORK_DIR/mobile.js" ] then info_cnt=`cat $WORK_DIR/admin_center.js | grep ".model]);if(Ext.isDefined" | wc -l` 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" ] then if [ "$MA_VER" -ge "6" ] then cpu_info="f.cpu_vendor=\\\"${cpu_vendor}\\\";f.cpu_family=\\\"${cpu_family}\\\";f.cpu_series=\\\"${cpu_series}\\\";f.cpu_cores=\\\"${cpu_cores}\\\";" sed -i "s/${cpu_info}//g" $WORK_DIR/admin_center.js cpu_info_m="{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}Core)', cpu_vendor, cpu_family, cpu_series, cpu_cores);},label: _T(\\\"status\\\", \\\"cpu_model_name\\\")}," sed -i "s/${cpu_info_m}//g" $MWORK_DIR/mobile.js if [ "$MI_VER" -ge "2" ] then cp -Rf $WORK_DIR/admin_center.js $WORK_DIR/admin_center.js.1 cp -Rf $MWORK_DIR/mobile.js $MWORK_DIR/mobile.js.1 gzip -f $WORK_DIR/admin_center.js gzip -f $MWORK_DIR/mobile.js mv $WORK_DIR/admin_center.js.1 $WORK_DIR/admin_center.js mv $MWORK_DIR/mobile.js.1 $MWORK_DIR/mobile.js fi else if [ "$MI_VER" -gt "0" ] then cpu_info="b.cpu_vendor=\\\"${cpu_vendor}\\\";b.cpu_family=\\\"${cpu_family}\\\";b.cpu_series=\\\"${cpu_series}\\\";b.cpu_cores=\\\"${cpu_cores}\\\";" else cpu_info="b.cpu_vendor=\\\"${cpu_vendor}\\\";b.cpu_family=\\\"${cpu_family} ${cpu_series}\\\";b.cpu_cores=\\\"${cpu_cores}\\\";" fi sed -i "s/${cpu_info}//g" $WORK_DIR/admin_center.js fi fi else COMMENT08_FN fi fi } BLCHECK_FN () { bl_check=n if [ -d "$BKUP_DIR" ] then BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | wc -l` if [ "$BK_CNT" -gt "0" ] then BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | grep "$BL_CHK" | wc -l` if [ "$BK_CNT" -gt "0" ] then TIME=`ls -l $BKUP_DIR/ | grep ^d | grep "$BL_CHK" | awk '{print $9}' | head -1` BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | grep -v "$BL_CHK" | wc -l` if [ "$BK_CNT" -gt "0" ] then BLSUB_FN "$1" else if [ "$re_check" == "n" ] then if [ "$1" == "run" ] then COMMENT03_FN fi COMMENT05_FN else STIME=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1` BLSUB_FN "redo" fi fi else if [ "$1" == "restore" ] then COMMENT07_FN fi BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | grep -v "$BL_CHK" | wc -l` if [ "$BK_CNT" -gt "0" ] then BL_COM=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1 | awk -F_ '{print $2}'` BL_CNT=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1 | awk -F_ '{print $2}' | wc -l` if [ "$BL_COM" == "" ] then if [ "$BL_CNT" -gt "0" ] then BLSUB_FN "$1" bl_check=y else COMMENT06_FN fi else TIME=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1` if [ "$BL_CHK" == "$BL_COM" ] then if [ "$1" == "run" ] then COMMENT03_FN else COMMENT05_FN bl_check=n fi else if [ "$BL_CHK" -gt "$BL_COM" ] then BLSUB_FN "$1" bl_check=y else COMMENT06_FN fi fi fi else COMMENT06_FN fi fi else CASE_FN "$1" fi else CASE_FN "$1" fi } BLSUB_FN () { TIME=`echo "$STIME"` if [ "$1" == "run" ] then RERUN_FN "redo" else RERUN_FN "$1" fi COMMENT05_FN } CASE_FN () { case "$1" in run) COMMENT05_FN ;; redo) COMMENT07_FN ;; restore) COMMENT07_FN ;; *) COMMENT06_FN ;; esac } EXEC_FN () { if [ -d $WORK_DIR ] then READ_YN "Auto Excute, If you select n, proceed interactively (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then mkdir -p $BKUP_DIR/$TIME if [ "$re_check" == "y" ] then if [ "$bl_check" == "y" ] then COMMENT04_FN else RECOVER_FN fi fi PREPARE_FN GATHER_FN PERFORM_FN APPLY_FN COMMENT09_FN elif [ "$Y_N" == "n" ] then READ_YN "Proceed with original file backup and preparation.. If you select n, Work directly on the original file. (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then mkdir -p $BKUP_DIR/$TIME if [ "$re_check" == "y" ] then if [ "$bl_check" == "y" ] then COMMENT04_FN else RECOVER_FN fi fi PREPARE_FN elif [ "$Y_N" == "n" ] then direct_job=y mkdir -p $BKUP_DIR PREPARE_FN else COMMENT10_FN fi READ_YN "CPU name, Core count and reflects it. If you select n, Resote original file (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then GATHER_FN PERFORM_FN APPLY_FN COMMENT09_FN elif [ "$Y_N" == "n" ] then if [ -d "$BKUP_DIR" ] then gzip $BKUP_DIR/admin_center.js gzip $BKUP_DIR/mobile.js mv $BKUP_DIR/admin_center.js.gz $WORK_DIR/ mv $BKUP_DIR/mobile.js.gz $MWORK_DIR/ COMMENT09_FN else COMMENT07_FN fi else COMMENT10_FN fi else COMMENT10_FN fi else COMMENT08_FN fi } COMMENT03_FN () { echo -e "There is a history of running the same version. Please run again select 2) redo .\n" exit 0 } COMMENT04_FN () { echo -e "Do not restore to source when installing a higher version. Contiue...\n" } COMMENT05_FN () { echo -e "You have verified and installed the previous version. Contiue...\n" } COMMENT06_FN () { echo -e "Problem and exit. Please run again after checking." exit 0 } COMMENT07_FN () { echo -e "No execution history. Please go back to the first run." exit 0 } COMMENT08_FN () { echo -e "The target file(location) does not exist. Please run again after checking." exit 0 } COMMENT09_FN () { 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.)" exit 0 } COMMENT10_FN () { echo -e "Only y / n / q can be input. Please proceed again." exit 0 } # ============================================================================== # Main Progress # ============================================================================== clear WORK_DIR="/usr/syno/synoman/webman/modules/AdminCenter" MWORK_DIR="/usr/syno/synoman/mobile/ui" BKUP_DIR="/root/Xpenology_backup" VER_DIR="/etc.default" echo "DSM CPU Information Change Tool ver. \033[0;31m"$ver"\033[00m - made by FOXBI\n" if [ -d "$VER_DIR" ] then VER_FIL="$VER_DIR/VERSION" else VER_FIL="/etc/VERSION" fi if [ -f "$VER_FIL" ] then MA_VER=`cat $VER_FIL | grep majorversion | awk -F \= '{print $2}' | sed 's/\"//g'` MI_VER=`cat $VER_FIL | grep minorversion | awk -F \= '{print $2}' | sed 's/\"//g'` BL_NUM=`cat $VER_FIL | grep buildnumber | awk -F \= '{print $2}' | sed 's/\"//g'` BL_FIX=`cat $VER_FIL | grep smallfixnumber | awk -F \= '{print $2}' | sed 's/\"//g'` else COMMENT08_FN fi BL_CHK=$BL_NUM$BL_FIX TIME=`date +%Y%m%d%H%M%S`"_"$BL_CHK STIME=`echo "$TIME"` if [ "$MA_VER" -gt "4" ] then if [ "$MA_VER" -eq "5" ] then MWORK_DIR="/usr/syno/synoman/webman/mapp" fi echo "Your version of DSM is \033[0;36mDSM \033[0;31m"$MA_VER"."$MI_VER"\033[0;32m continue...\n" else echo "DSM version less than 5 is not supported. End the process." exit 0 fi read -n1 -p "1) First run 2) Redo 3) Restore - Select Number : " inst_z case "$inst_z" in 1) inst_check=run echo -e "\n " ;; 2) inst_check=redo echo -e "\n " ;; 3) inst_check=restore echo -e "\n " ;; *) echo -e "\n" ;; esac if [ "$inst_check" == "redo" ] then READ_YN "Do you want to proceed again? Restore to original file backup and proceed.(Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then re_check=y BLCHECK_FN "$inst_check" inst_check=run EXEC_FN elif [ "$Y_N" == "n" ] then echo "Do not proceed with the redo." else COMMENT10_FN fi elif [ "$inst_check" == "restore" ] then READ_YN "Do you want to restore using the original backup file? (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then re_check=n BLCHECK_FN "$inst_check" RECOVER_FN elif [ "$Y_N" == "n" ] then echo "No restore was performed." else COMMENT10_FN fi elif [ "$inst_check" == "run" ] then re_check=n BLCHECK_FN "$inst_check" EXEC_FN else echo "Please select the correct number." fi You have nothing to be embarrassed about, FOXBI! Your code is much more elegant than some of my bash scripts 😉 감사합니다 !! Unfortunately, it still doesn't quite work for me - it recognizes my Core i3-6100T (specs) correctly, but it says I have 4 CPU cores: when in fact there are only 2. I am not sure why it thinks so, the commands get it right: # dmidecode -t processor # dmidecode 2.12 SMBIOS 3.0 present. # SMBIOS implementations newer than version 2.7 are not # fully supported by this version of dmidecode. Handle 0x000C, DMI type 4, 48 bytes Processor Information Socket Designation: CPUSocket Type: Central Processor Family: Core i3 Manufacturer: Intel(R) Corporation ID: E3 06 05 00 FF FB EB BF Signature: Type 0, Family 6, Model 94, Stepping 3 Flags: FPU (Floating-point unit on-chip) VME (Virtual mode extension) DE (Debugging extension) PSE (Page size extension) TSC (Time stamp counter) MSR (Model specific registers) PAE (Physical address extension) MCE (Machine check exception) CX8 (CMPXCHG8 instruction supported) APIC (On-chip APIC hardware supported) SEP (Fast system call) MTRR (Memory type range registers) PGE (Page global enable) MCA (Machine check architecture) CMOV (Conditional move instruction supported) PAT (Page attribute table) PSE-36 (36-bit page size extension) CLFSH (CLFLUSH instruction supported) DS (Debug store) ACPI (ACPI supported) MMX (MMX technology supported) FXSR (FXSAVE and FXSTOR instructions supported) SSE (Streaming SIMD extensions) SSE2 (Streaming SIMD extensions 2) SS (Self-snoop) HTT (Multi-threading) TM (Thermal monitor supported) PBE (Pending break enabled) Version: Intel(R) Core(TM) i3-6100T CPU @ 3.20GHz Voltage: 1.1 V External Clock: 100 MHz Max Speed: 3200 MHz Current Speed: 3200 MHz Status: Populated, Enabled Upgrade: Other L1 Cache Handle: 0x0009 L2 Cache Handle: 0x000A L3 Cache Handle: 0x000B Serial Number: To Be Filled By O.E.M. Asset Tag: To Be Filled By O.E.M. Part Number: To Be Filled By O.E.M. Core Count: 2 Core Enabled: 2 Thread Count: 4 Characteristics: 64-bit capable Multi-Core Hardware Thread Execute Protection Enhanced Virtualization Power/Performance Control # cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 94 model name : Intel(R) Core(TM) i3-6100T CPU @ 3.20GHz stepping : 3 microcode : 0xc2 cpu MHz : 3101.000 cache size : 3072 KB physical id : 0 siblings : 4 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch ida arat epb xsaveopt pln pts invpcid_single spec_ctrl ibpb_support tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap bogomips : 6384.58 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: Maybe your code is confusing number of threads with number of cores? Thanks again 😊 1 Quote Link to comment Share on other sites More sharing options...
gericb Posted October 27, 2018 Share #37 Posted October 27, 2018 On 10/26/2018 at 8:33 PM, Vileserver said: Maybe your code is confusing number of threads with number of cores? Thanks again 😊 That's exactly what I was trying to share in my earlier post, if just based on the numbers alone....don't know if it's displaying based on Hyper-Threading capable. 🤔 1 Quote Link to comment Share on other sites More sharing options...
Vileserver Posted October 27, 2018 Share #38 Posted October 27, 2018 2 hours ago, gericb said: That's exactly what I was trying to share in my earlier post, if just based on the numbers alone....don't know if it's displaying based on Hyper-Threading capable. 🤔 Before I ran FOXBI's script, the specs said 4 cores for Xeon D-1527, which is the CPU in the DS3617xs: Note this is the number of cores, NOT threads which would be 8 for this CPU! Check Intel's datasheet here. So DSM is always meant to show physical cores, not logical ones. Therefore this is a small bug in the script.... 1 1 Quote Link to comment Share on other sites More sharing options...
Vileserver Posted October 29, 2018 Share #39 Posted October 29, 2018 OK, here is a slightly updated version, I call it 4.01. Fixes: improve CPU core determination fix color output fix typos Thanks again to FOXBI for this great script! I hope you don't mind me making some small changes to it. gericb, does this work for you? Spoiler #!/bin/bash # ver 4.01 2018.10.28 Made by Vileserver (fix CPU core determination) # ver 4.0 2018.09.13 Made by FOXBI # ver 3.0 2018.08.24 Made by FOXBI # Ver 1.5 2018.08.23 Made by FOXBI # Ver 1.1 2018.08.22 Made by FOXBI # Ver 1.0 2018.08.17 Made by FOXBI ver="4.01" # ============================================================================== # Y or N Function # ============================================================================== READ_YN () { # $1:question $2:default read -n1 -p "$1" Y_N case "$Y_N" in y) Y_N="y" echo -e "\n" ;; n) Y_N="n" echo -e "\n" ;; q) echo -e "\n" exit 0 ;; *) echo -e "\n" ;; esac } # ============================================================================== # Process Function # ============================================================================== PREPARE_FN () { if [ -f "$WORK_DIR/admin_center.js" ] && [ -f "$MWORK_DIR/mobile.js" ] then if [ "$direct_job" == "y" ] then echo "warning!! Work directly on the original file without backup.\n" else cd $WORK_DIR tar -cf $BKUP_DIR/$TIME/admin_center.tar admin_center.js* cd $MWORK_DIR tar -cf $BKUP_DIR/$TIME/mobile.tar mobile.js* 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/ cd $BKUP_DIR/ gzip -df $BKUP_DIR/admin_center.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/ fi else COMMENT08_FN fi } GATHER_FN () { DMI_CHK=`dmidecode | grep 'SMBIOS' | egrep 'NO|sorry' | wc -l` if [ "$DMI_CHK" -gt "0" ] then cpu_vendor=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $4}'` if [ "$cpu_vendor" == "AMD" ] then cpu_family=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk -F "$cpu_vendor " '{ print $2 }' | awk -F "Processor" '{ print $1 }'` cpu_series="" else cpu_family=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $5}'` cpu_series=`cat /proc/cpuinfo | grep model | grep name | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{ if (index($7,"@")!=0) { print $6 } else { print $6" "$7 } }'` fi else cpu_vendor=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $2}'` if [ "$cpu_vendor" == "AMD" ] then cpu_family=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk -F "$cpu_vendor " '{ print $2 }' | awk -F "Processor" '{ print $1 }'` cpu_series="" else cpu_family=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{print $3}'` cpu_series=`dmidecode -t processor | grep Version | grep -v Unknown | grep -v Not | sort -u | sed "s/(.)//g" | sed "s/(..)//g" | sed "s/CPU//g" | awk '{ if (index($5,"@")!=0) { print $4 } else { print $4" "$5 } }'` fi fi cpu_cores=`grep '^cpu cores' /proc/cpuinfo | uniq | awk '{print $4}'` } PERFORM_FN () { if [ -f "$BKUP_DIR/admin_center.js" ] && [ -f "$BKUP_DIR/mobile.js" ] then if [ "$MA_VER" -ge "6" ] then cpu_info=`echo "f.cpu_vendor=\"${cpu_vendor}\";f.cpu_family=\"${cpu_family}\";f.cpu_series=\"${cpu_series}\";f.cpu_cores=\"${cpu_cores}\";"` sed -i "s/f.model]);/f.model]);${cpu_info}/g" $BKUP_DIR/admin_center.js 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}Core)', 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 if [ "$MI_VER" -gt "0" ] then cpu_info=`echo "b.cpu_vendor=\"${cpu_vendor}\";b.cpu_family=\"${cpu_family}\";b.cpu_series=\"${cpu_series}\";b.cpu_cores=\"${cpu_cores}\";"` else cpu_info=`echo "b.cpu_vendor=\"${cpu_vendor}\";b.cpu_family=\"${cpu_family} ${cpu_series}\";b.cpu_cores=\"${cpu_cores}\";"` fi sed -i "s/b.model]);/b.model]);${cpu_info}/g" $BKUP_DIR/admin_center.js fi else COMMENT08_FN fi } APPLY_FN () { if [ -f "$BKUP_DIR/admin_center.js" ] && [ -f "$BKUP_DIR/mobile.js" ] then cp -Rf $BKUP_DIR/admin_center.js $WORK_DIR/ cp -Rf $BKUP_DIR/mobile.js $MWORK_DIR/ if [ "$MA_VER" -eq "6" ] && [ "$MI_VER" -ge "2" ] then gzip -f $BKUP_DIR/admin_center.js gzip -f $BKUP_DIR/mobile.js mv $BKUP_DIR/admin_center.js.gz $WORK_DIR/ mv $BKUP_DIR/mobile.js.gz $MWORK_DIR/ else rm -rf $BKUP_DIR/admin_center.js rm -rf $BKUP_DIR/mobile.js fi else COMMENT08_FN fi } RECOVER_FN () { if [ -d "$BKUP_DIR/$TIME" ] then cd $WORK_DIR tar -xf $BKUP_DIR/$TIME/admin_center.tar if [ -f "$BKUP_DIR/$TIME/mobile.tar" ] then cd $MWORK_DIR tar -xf $BKUP_DIR/$TIME/mobile.tar fi if [ "$re_check" == "y" ] then echo -e "Restore to source and continue.\n" else COMMENT09_FN fi else COMMENT08_FN fi } RERUN_FN () { if [ "$1" == "redo" ] then ls -l $BKUP_DIR/ | grep ^d | grep -v "$BL_CHK" | awk '{print "rm -rf '$BKUP_DIR'/"$9}' | sh GATHER_FN if [ -f "$WORK_DIR/admin_center.js" ] && [ -f "$MWORK_DIR/mobile.js" ] then info_cnt=`cat $WORK_DIR/admin_center.js | grep ".model]);if(Ext.isDefined" | wc -l` 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" ] then if [ "$MA_VER" -ge "6" ] then cpu_info="f.cpu_vendor=\\\"${cpu_vendor}\\\";f.cpu_family=\\\"${cpu_family}\\\";f.cpu_series=\\\"${cpu_series}\\\";f.cpu_cores=\\\"${cpu_cores}\\\";" sed -i "s/${cpu_info}//g" $WORK_DIR/admin_center.js cpu_info_m="{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}Core)', cpu_vendor, cpu_family, cpu_series, cpu_cores);},label: _T(\\\"status\\\", \\\"cpu_model_name\\\")}," sed -i "s/${cpu_info_m}//g" $MWORK_DIR/mobile.js if [ "$MI_VER" -ge "2" ] then cp -Rf $WORK_DIR/admin_center.js $WORK_DIR/admin_center.js.1 cp -Rf $MWORK_DIR/mobile.js $MWORK_DIR/mobile.js.1 gzip -f $WORK_DIR/admin_center.js gzip -f $MWORK_DIR/mobile.js mv $WORK_DIR/admin_center.js.1 $WORK_DIR/admin_center.js mv $MWORK_DIR/mobile.js.1 $MWORK_DIR/mobile.js fi else if [ "$MI_VER" -gt "0" ] then cpu_info="b.cpu_vendor=\\\"${cpu_vendor}\\\";b.cpu_family=\\\"${cpu_family}\\\";b.cpu_series=\\\"${cpu_series}\\\";b.cpu_cores=\\\"${cpu_cores}\\\";" else cpu_info="b.cpu_vendor=\\\"${cpu_vendor}\\\";b.cpu_family=\\\"${cpu_family} ${cpu_series}\\\";b.cpu_cores=\\\"${cpu_cores}\\\";" fi sed -i "s/${cpu_info}//g" $WORK_DIR/admin_center.js fi fi else COMMENT08_FN fi fi } BLCHECK_FN () { bl_check=n if [ -d "$BKUP_DIR" ] then BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | wc -l` if [ "$BK_CNT" -gt "0" ] then BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | grep "$BL_CHK" | wc -l` if [ "$BK_CNT" -gt "0" ] then TIME=`ls -l $BKUP_DIR/ | grep ^d | grep "$BL_CHK" | awk '{print $9}' | head -1` BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | grep -v "$BL_CHK" | wc -l` if [ "$BK_CNT" -gt "0" ] then BLSUB_FN "$1" else if [ "$re_check" == "n" ] then if [ "$1" == "run" ] then COMMENT03_FN fi COMMENT05_FN else STIME=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1` BLSUB_FN "redo" fi fi else if [ "$1" == "restore" ] then COMMENT07_FN fi BK_CNT=`ls -l $BKUP_DIR/ | grep ^d | grep -v "$BL_CHK" | wc -l` if [ "$BK_CNT" -gt "0" ] then BL_COM=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1 | awk -F_ '{print $2}'` BL_CNT=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1 | awk -F_ '{print $2}' | wc -l` if [ "$BL_COM" == "" ] then if [ "$BL_CNT" -gt "0" ] then BLSUB_FN "$1" bl_check=y else COMMENT06_FN fi else TIME=`ls -l $BKUP_DIR/ | grep ^d | awk '{print $9}' | head -1` if [ "$BL_CHK" == "$BL_COM" ] then if [ "$1" == "run" ] then COMMENT03_FN else COMMENT05_FN bl_check=n fi else if [ "$BL_CHK" -gt "$BL_COM" ] then BLSUB_FN "$1" bl_check=y else COMMENT06_FN fi fi fi else COMMENT06_FN fi fi else CASE_FN "$1" fi else CASE_FN "$1" fi } BLSUB_FN () { TIME=`echo "$STIME"` if [ "$1" == "run" ] then RERUN_FN "redo" else RERUN_FN "$1" fi COMMENT05_FN } CASE_FN () { case "$1" in run) COMMENT05_FN ;; redo) COMMENT07_FN ;; restore) COMMENT07_FN ;; *) COMMENT06_FN ;; esac } EXEC_FN () { if [ -d $WORK_DIR ] then READ_YN "Auto Execute, If you select n, proceed interactively (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then mkdir -p $BKUP_DIR/$TIME if [ "$re_check" == "y" ] then if [ "$bl_check" == "y" ] then COMMENT04_FN else RECOVER_FN fi fi PREPARE_FN GATHER_FN PERFORM_FN APPLY_FN COMMENT09_FN elif [ "$Y_N" == "n" ] then READ_YN "Proceed with original file backup and preparation.. If you select n, Work directly on the original file. (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then mkdir -p $BKUP_DIR/$TIME if [ "$re_check" == "y" ] then if [ "$bl_check" == "y" ] then COMMENT04_FN else RECOVER_FN fi fi PREPARE_FN elif [ "$Y_N" == "n" ] then direct_job=y mkdir -p $BKUP_DIR PREPARE_FN else COMMENT10_FN fi READ_YN "CPU name, Core count and reflects it. If you select n, Restore original file (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then GATHER_FN PERFORM_FN APPLY_FN COMMENT09_FN elif [ "$Y_N" == "n" ] then if [ -d "$BKUP_DIR" ] then gzip $BKUP_DIR/admin_center.js gzip $BKUP_DIR/mobile.js mv $BKUP_DIR/admin_center.js.gz $WORK_DIR/ mv $BKUP_DIR/mobile.js.gz $MWORK_DIR/ COMMENT09_FN else COMMENT07_FN fi else COMMENT10_FN fi else COMMENT10_FN fi else COMMENT08_FN fi } COMMENT03_FN () { echo -e "There is a history of running the same version. Please run again select 2) redo .\n" exit 0 } COMMENT04_FN () { echo -e "Do not restore to source when installing a higher version. Continue...\n" } COMMENT05_FN () { echo -e "You have verified and installed the previous version. Continue...\n" } COMMENT06_FN () { echo -e "Problem and exit. Please run again after checking." exit 0 } COMMENT07_FN () { echo -e "No execution history. Please go back to the first run." exit 0 } COMMENT08_FN () { echo -e "The target file(location) does not exist. Please run again after checking." exit 0 } COMMENT09_FN () { 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.)" exit 0 } COMMENT10_FN () { echo -e "Only y / n / q can be input. Please proceed again." exit 0 } # ============================================================================== # Main Progress # ============================================================================== clear WORK_DIR="/usr/syno/synoman/webman/modules/AdminCenter" MWORK_DIR="/usr/syno/synoman/mobile/ui" BKUP_DIR="/root/Xpenology_backup" VER_DIR="/etc.default" echo -e "DSM CPU Information Change Tool ver. \033[0;31m"$ver"\033[00m - made by FOXBI\n" if [ -d "$VER_DIR" ] then VER_FIL="$VER_DIR/VERSION" else VER_FIL="/etc/VERSION" fi if [ -f "$VER_FIL" ] then MA_VER=`cat $VER_FIL | grep majorversion | awk -F \= '{print $2}' | sed 's/\"//g'` MI_VER=`cat $VER_FIL | grep minorversion | awk -F \= '{print $2}' | sed 's/\"//g'` BL_NUM=`cat $VER_FIL | grep buildnumber | awk -F \= '{print $2}' | sed 's/\"//g'` BL_FIX=`cat $VER_FIL | grep smallfixnumber | awk -F \= '{print $2}' | sed 's/\"//g'` else COMMENT08_FN fi BL_CHK=$BL_NUM$BL_FIX TIME=`date +%Y%m%d%H%M%S`"_"$BL_CHK STIME=`echo "$TIME"` if [ "$MA_VER" -gt "4" ] then if [ "$MA_VER" -eq "5" ] then MWORK_DIR="/usr/syno/synoman/webman/mapp" fi echo -e "Your version of DSM is \033[0;36mDSM \033[0;31m"$MA_VER"."$MI_VER"\033[0;32m continue...\033[00m\n" else echo "DSM version less than 5 is not supported. End the process." exit 0 fi read -n1 -p "1) First run 2) Redo 3) Restore - Select Number : " inst_z case "$inst_z" in 1) inst_check=run echo -e "\n " ;; 2) inst_check=redo echo -e "\n " ;; 3) inst_check=restore echo -e "\n " ;; *) echo -e "\n" ;; esac if [ "$inst_check" == "redo" ] then READ_YN "Do you want to proceed again? Restore to original file backup and proceed.(Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then re_check=y BLCHECK_FN "$inst_check" inst_check=run EXEC_FN elif [ "$Y_N" == "n" ] then echo "Do not proceed with the redo." else COMMENT10_FN fi elif [ "$inst_check" == "restore" ] then READ_YN "Do you want to restore using the original backup file? (Cancel : q) [y/n] : " if [ "$Y_N" == "y" ] then re_check=n BLCHECK_FN "$inst_check" RECOVER_FN elif [ "$Y_N" == "n" ] then echo "No restore was performed." else COMMENT10_FN fi elif [ "$inst_check" == "run" ] then re_check=n BLCHECK_FN "$inst_check" EXEC_FN else echo "Please select the correct number." fi 1 Quote Link to comment Share on other sites More sharing options...
FOXBI Posted October 30, 2018 Author Share #40 Posted October 30, 2018 On 10/25/2018 at 9:47 PM, Olegin said: @FOXBI It seems, that don't work on 6.2.1 with 1.04b loader. UPD: After reboot - ok. Sorry, I have not yet prepared the 1.04b environment. I'll check it later when I'm ready. Quote Link to comment Share on other sites More sharing options...
FOXBI Posted October 30, 2018 Author Share #41 Posted October 30, 2018 11 hours ago, Vileserver said: OK, here is a slightly updated version, I call it 4.01. Fixes: improve CPU core determination fix color output fix typos Thanks again to FOXBI for this great script! I hope you don't mind me making some small changes to it. gericb, does this work for you? Sorry. Unfortunately, you modified it to 4.01, and I also updated the 5.0 new version. In addition, i'll check the fix part and reflect it later. Quote Link to comment Share on other sites More sharing options...
FOXBI Posted October 30, 2018 Author Share #42 Posted October 30, 2018 (edited) On 8/17/2018 at 11:41 PM, FOXBI said: ch_cpuinfo ver 5.0 - update new version -> ch_cpuinfo_en.tar -> ch_cpuinfo_ko.tar I uploaded a new version file that change to core information collection method. It's possible to use !! I made a mistaken judgment by my business habits. I apologize for the wrong information. Edited October 30, 2018 by FOXBI some edited comment Quote Link to comment Share on other sites More sharing options...
Vileserver Posted October 30, 2018 Share #43 Posted October 30, 2018 9 hours ago, FOXBI said: I uploaded a new version file that change to core information collection method. It's possible to use !! Fantastic! Thanks FOXBI. Any chance you can also post the shell script? I think most users here prefer the bash source. Thanks 😊 1 Quote Link to comment Share on other sites More sharing options...
FOXBI Posted October 31, 2018 Author Share #44 Posted October 31, 2018 8 hours ago, Vileserver said: Fantastic! Thanks FOXBI. Any chance you can also post the shell script? I think most users here prefer the bash source. Sorry, I'm afraid I have to show you next time. The code in this section is not complicated, but the current source for the CPU core is the code I made for use in my work area. It is likely to be misunderstood as business data leakage by me. so, I think possible to disclose after changing some variables and contents. I would be grateful if you could wait a little longer. Add to.. It's actually in the main topic. It is not a difficult part because it is produced through the values collected by the following five variables. cat /proc/cpuinfo | grep "processor" | sort -u | wc -l cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l cat /proc/cpuinfo | grep "core id" | sort -u | wc -l cat /proc/cpuinfo | grep "siblings" | sort -u | awk '{print $NF}' cat /proc/cpuinfo | grep "cpu cores" | sort -u | awk '{print $NF}' 1 Quote Link to comment Share on other sites More sharing options...
Vileserver Posted October 31, 2018 Share #45 Posted October 31, 2018 6 hours ago, FOXBI said: It is not a difficult part because it is produced through the values collected by the following five variables. cat /proc/cpuinfo | grep "processor" | sort -u | wc -l cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l cat /proc/cpuinfo | grep "core id" | sort -u | wc -l cat /proc/cpuinfo | grep "siblings" | sort -u | awk '{print $NF}' cat /proc/cpuinfo | grep "cpu cores" | sort -u | awk '{print $NF}' You can actually get the number of CPU cores in just one line, like this: grep '^cpu cores' /proc/cpuinfo | uniq | awk '{print $4}' This works for CPUs that have hyper-threading. There are some more interesting methods discussed here: http://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line 1 Quote Link to comment Share on other sites More sharing options...
FOXBI Posted October 31, 2018 Author Share #46 Posted October 31, 2018 20 minutes ago, Vileserver said: You can actually get the number of CPU cores in just one line, like this: grep '^cpu cores' /proc/cpuinfo | uniq | awk '{print $4}' This works for CPUs that have hyper-threading. There are some more interesting methods discussed here: http://stackoverflow.com/questions/6481005/how-to-obtain-the-number-of-cpus-cores-in-linux-from-the-command-line Thanks for the advice. But, The result value of your code is same to one of my codes below. cat /proc/cpuinfo | grep "cpu cores" | sort -u | awk '{print $NF}' If I was just extracting core values, I would have used only one line. The remaining values are collected to make the most of the number of cpu, HT support, vm, intel, amd, openstack, and docker environments.(It may not be perfect.) I will reference to your link. Thank you very much!! 1 Quote Link to comment Share on other sites More sharing options...
Vileserver Posted October 31, 2018 Share #47 Posted October 31, 2018 Thank you FOXBI. As always, I am looking forward to the bash source of your script! 😃 1 Quote Link to comment Share on other sites More sharing options...
gericb Posted November 2, 2018 Share #48 Posted November 2, 2018 On 10/30/2018 at 1:18 AM, FOXBI said: I uploaded a new version file that change to core information collection method. It's possible to use !! I made a mistaken judgment by my business habits. I apologize for the wrong information. SUCCESS! Correct # of cores being displayed, and I appreciate the extra CPU stats presented from the v5.0 1 Quote Link to comment Share on other sites More sharing options...
LDiamond Posted November 5, 2018 Share #49 Posted November 5, 2018 (edited) Its ok Edited November 5, 2018 by LDiamond edit 1 Quote Link to comment Share on other sites More sharing options...
LDiamond Posted November 5, 2018 Share #50 Posted November 5, 2018 (edited) SynoManager third-party program still shows the same as in the original. Edited November 5, 2018 by LDiamond edit 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.