|
|
@@ -0,0 +1,137 @@
|
|
|
+#!/bin/bash
|
|
|
+MY_PATH="`dirname \"$0\"`" # relative
|
|
|
+# echo "1"$MY_PATH
|
|
|
+MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
|
+
|
|
|
+
|
|
|
+echo "[RVCTermianal] === Install Start === "
|
|
|
+echo "result=-1&msg=install begin" > `pwd`/install.log
|
|
|
+rvc_install_path_root="/opt"
|
|
|
+rvc_install_path_rvc_dir=${rvc_install_path_root}/rvc
|
|
|
+rvc_install_path_Run_dir=${rvc_install_path_root}/Run
|
|
|
+rvc_install_path_hardware_dir=${rvc_install_path_Run_dir}/hardwarecfg
|
|
|
+rvc_install_path_versions_dir=${rvc_install_path_Run_dir}/version
|
|
|
+
|
|
|
+
|
|
|
+#detect the usr input the vendor or not
|
|
|
+has_vendor=0
|
|
|
+tolower_vendor=''
|
|
|
+upper_vendor=''
|
|
|
+if [ $# -eq 1 ];then
|
|
|
+ has_vendor=1
|
|
|
+ echo has arguments: $*
|
|
|
+ tolower_vendor=$(echo $1 | awk '{ print tolower($0) }' )
|
|
|
+ upper_vendor=$(echo $1 | awk '{ print toupper($0) }' )
|
|
|
+else
|
|
|
+ echo no any arguments.
|
|
|
+fi
|
|
|
+
|
|
|
+# to detect zipped pkg is exist or not
|
|
|
+pkgs=$(sudo find ${MY_PATH} -type f -name *.tar.gz | head -n 1)
|
|
|
+if [ "#${pkgs}" = "#" ]
|
|
|
+then
|
|
|
+ echo Fail to find tar install package !!
|
|
|
+ exit 1
|
|
|
+else
|
|
|
+ echo ${pkgs}
|
|
|
+fi
|
|
|
+
|
|
|
+cur_pkg=${pkgs}
|
|
|
+slen=${#cur_pkg}
|
|
|
+cur_pkg_len=$((${slen}-6))
|
|
|
+cur_pkg_exists_dir=$(echo $cur_pkg | awk '{ print substr($0,0,length($0)-6) }') #.tar.gz
|
|
|
+echo ${cur_pkg_exists_dir}
|
|
|
+
|
|
|
+# remove the unzipped files if exists
|
|
|
+if [ -d $cur_pkg_exists_dir ]; then
|
|
|
+ echo "to remove unzipped exists directory"
|
|
|
+ sudo rm -rf ${cur_pkg_exists_dir}
|
|
|
+fi
|
|
|
+
|
|
|
+# unzip the zipped pkg.
|
|
|
+echo to unzip $cur_pkg ...
|
|
|
+tar -xzvf $cur_pkg
|
|
|
+echo unzip $cur_pkg done!
|
|
|
+
|
|
|
+# fetch the version full path at pkg
|
|
|
+version_dir=$(find ${cur_pkg_exists_dir}/Run/version/ -maxdepth 1 -regex ".*[0-9\.]$" -type d)
|
|
|
+echo version dir: $version_dir
|
|
|
+slen=${#cur_pkg_exists_dir}
|
|
|
+rel_version_dir=${version_dir:$slen+1}
|
|
|
+echo ${rel_version_dir}
|
|
|
+
|
|
|
+#if [ $has_vendor -eq 1 ];then
|
|
|
+# bak=${cur_pkg}_bak
|
|
|
+# sudo rm -rf ${bak}
|
|
|
+# sudo mkdir -p ${bak}
|
|
|
+# sudo cp -R 'find ${version_dir} -type d -path ${version_dir}/dep -prune -o -print | sed 1d' ${bak}
|
|
|
+#fi
|
|
|
+
|
|
|
+
|
|
|
+# to copy thirdparty libraries
|
|
|
+
|
|
|
+# deal with libcef.so
|
|
|
+if [ ! -f "$version_dir/bin/Chromium/libcef.so" -a ! -f "/usr/lib/libcef.so" ];then
|
|
|
+ echo cannot found libcef.so !!!
|
|
|
+ exit 1
|
|
|
+else if [ ! -f "/usr/lib/libcef.so" ];then
|
|
|
+ echo to mv libcef.so...
|
|
|
+ sudo mv $version_dir/bin/Chromium/libcef.so /usr/lib/
|
|
|
+ echo mv libcef.so done!
|
|
|
+else if [ -f "$version_dir/bin/Chromium/libcef.so" ]; then
|
|
|
+ sudo rm $version_dir/bin/Chromium/libcef.so
|
|
|
+fi
|
|
|
+fi
|
|
|
+fi
|
|
|
+sudo chmod 644 /usr/lib/libcef.so
|
|
|
+
|
|
|
+#delete /opt/rvc
|
|
|
+# sudo rm -rf ${rvc_install_path_rvc_dir}
|
|
|
+
|
|
|
+if [ ! -f $rvc_install_path_hardware_dir/root.ini ]; then
|
|
|
+ #delete /opt/Run
|
|
|
+ sudo rm -rf ${rvc_install_path_Run_dir}
|
|
|
+else
|
|
|
+ echo has root.ini at hardware folder!! do not remove Run base dir.
|
|
|
+fi
|
|
|
+
|
|
|
+
|
|
|
+#copy the Run pkg to run path
|
|
|
+echo to copy Run package...
|
|
|
+sudo cp -rvf $cur_pkg_exists_dir/Run ${rvc_install_path_root}
|
|
|
+echo copy Run package completely!
|
|
|
+
|
|
|
+#copy the res pkg to rvc path
|
|
|
+echo to copy rvc Audio files...
|
|
|
+if [ ! -d $rvc_install_path_rvc_dir ]; then
|
|
|
+ sudo mkdir -p ${rvc_install_path_rvc_dir}
|
|
|
+fi
|
|
|
+sudo cp -rvf $cur_pkg_exists_dir/Data/Audio ${rvc_install_path_rvc_dir}/addata
|
|
|
+echo copy rvc Audio files completely!
|
|
|
+
|
|
|
+echo change the run scripts priviledge...
|
|
|
+echo ${rvc_install_path_rvc_dir}
|
|
|
+echo ${rvc_install_path_root}/${rel_version_dir}
|
|
|
+sudo chmod 766 -R ${rvc_install_path_rvc_dir}
|
|
|
+sudo chmod 666 -R ${rvc_install_path_hardware_dir}
|
|
|
+sudo chmod 777 -R ${rvc_install_path_root}/${rel_version_dir}
|
|
|
+sudo chmod 777 ${rvc_install_path_versions_dir}/spexplorer.sh
|
|
|
+sudo chmod 777 ${rvc_install_path_versions_dir}/sudo_spexplorer.sh
|
|
|
+echo change the run scripts priviledge done!
|
|
|
+
|
|
|
+if [ $has_vendor -eq 1 ];then
|
|
|
+ root_file=$rvc_install_path_hardware_dir/root.ini
|
|
|
+ root_vendor_file=$rvc_install_path_hardware_dir/root.ini.$tolower_vendor
|
|
|
+ if [ -f $root_vendor_file ] # ! -f $root_file -a
|
|
|
+ then
|
|
|
+ echo copy root.ini
|
|
|
+ sudo cp $root_vendor_file $root_file
|
|
|
+ fi
|
|
|
+fi
|
|
|
+
|
|
|
+echo "result=0&msg=install ok" > `pwd`/install.log
|
|
|
+chmod 777 `pwd`/install.log
|
|
|
+
|
|
|
+echo "[RVCTermianal] all install work done completely!!!"
|
|
|
+
|
|
|
+exit 0
|