upgrade.sh 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/bash
  2. MY_PATH="`dirname \"$0\"`" # relative
  3. # echo "1"$MY_PATH
  4. MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
  5. echo "[RVCTermianal] === Install Start === "
  6. rvc_install_path_root="/opt"
  7. rvc_install_path_rvc_dir=${rvc_install_path_root}/rvc
  8. rvc_install_path_Run_dir=${rvc_install_path_root}/Run
  9. rvc_install_path_hardware_dir=${rvc_install_path_Run_dir}/hardwarecfg
  10. rvc_install_path_versions_dir=${rvc_install_path_Run_dir}/version
  11. # check root priviledge
  12. if [ $(id -u) != 0 ]; then
  13. echo "[ERROR] === 该安装脚本需要以ROOT权限启动,请在命令行窗口添加sudo指令执行 'sudo bash $0',如果无法执行相关指令,请先确认系统已开启开发者模式 ==="
  14. exit 0
  15. fi
  16. argument1=
  17. if [ $# -eq 1 ];then
  18. echo has arguments: $*
  19. argument1=$(echo $1 | awk '{ print tolower($0) }' )
  20. else
  21. echo no any arguments.
  22. fi
  23. if [ "$argument1" = "pure" ]; then
  24. killall -9 spshell > /dev/null 2>&1
  25. killall -9 sphost > /dev/null 2>&1
  26. killall -9 guardian > /dev/null 2>&1
  27. killall -9 uosbrowser > /dev/null 2>&1
  28. killall -9 browser > /dev/null 2>&1
  29. killall -s 9 `ps -aux | grep browser | awk '{print $2}'` > /dev/null 2>&1
  30. fi
  31. # fetch the version full path at pkg
  32. version_dir=$(find ${MY_PATH}/Run/version/ -maxdepth 1 -regex ".*[0-9\.]$" -type d)
  33. echo version dir: $version_dir
  34. slen=${#MY_PATH}
  35. rel_version_dir=${version_dir:$slen+1}
  36. echo ${rel_version_dir}
  37. if [ ! -f $rvc_install_path_hardware_dir/root.ini ]; then
  38. #delete /opt/Run
  39. sudo rm -rf ${rvc_install_path_Run_dir}
  40. else
  41. echo root.ini 文件已存在,跳过清除 Run 文件夹.
  42. if [ -f ${MY_PATH}/Run/hardwarecfg/root.ini ]; then
  43. sudo rm ${MY_PATH}/Run/hardwarecfg/root.ini
  44. fi
  45. if [ -d ${MY_PATH}/Run/runinfo ]; then
  46. sudo rm -rf ${MY_PATH}/Run/runinfo
  47. fi
  48. fi
  49. #copy the Run pkg to run path
  50. echo to copy Run package...
  51. if [ ! -d $rvc_install_path_Run_dir ]; then
  52. sudo mkdir -p ${$rvc_install_path_Run_dir}
  53. fi
  54. sudo cp -rvf $MY_PATH/Run ${rvc_install_path_root}
  55. echo copy Run package completely!
  56. #copy the res pkg to rvc path
  57. echo to copy rvc Audio files...
  58. if [ ! -d $rvc_install_path_rvc_dir ]; then
  59. sudo mkdir -p ${rvc_install_path_rvc_dir}
  60. fi
  61. if [ ! -d $rvc_install_path_rvc_dir/adData ]; then
  62. sudo mkdir -p ${rvc_install_path_rvc_dir}/adData
  63. fi
  64. sudo cp -rvf $MY_PATH/rvc/adData/Audio ${rvc_install_path_rvc_dir}/adData
  65. echo copy rvc Audio files completely!
  66. #sudo cp -rvf $MY_PATH/rvc/adData/Video ${rvc_install_path_rvc_dir}/adData
  67. #echo copy rvc Video files completely!
  68. echo change the run scripts priviledge...
  69. echo ${rvc_install_path_rvc_dir}
  70. echo ${rvc_install_path_root}/${rel_version_dir}
  71. sudo chmod 777 ${rvc_install_path_root}
  72. sudo chmod a+rw -R ${rvc_install_path_rvc_dir}
  73. sudo chmod a+rw -R ${rvc_install_path_hardware_dir}
  74. sudo chmod 777 -R ${rvc_install_path_root}/${rel_version_dir}
  75. sudo chmod 777 ${rvc_install_path_versions_dir}/spexplorer.sh
  76. sudo chmod 777 ${rvc_install_path_versions_dir}/sudo_spexplorer.sh
  77. sudo chmod a+rw ${rvc_install_path_versions_dir}/active.txt
  78. echo change the run scripts priviledge done!
  79. echo "[RVCTermianal] === Install Done ! === "
  80. echo "[RVCTermianal] === 所有步骤执行成功,正常退出=== "
  81. exit 0