Sfoglia il codice sorgente

Z991239-5285 #comment 信创区分安装场景的脚本

80374374 1 anno fa
parent
commit
122ef85eb7
6 ha cambiato i file con 370 aggiunte e 377 eliminazioni
  1. 2 1
      CMakeLists.txt
  2. 6 0
      addin/Readme.txt
  3. 0 25
      addin/Run.ini.in
  4. 273 30
      addin/install.sh
  5. 0 321
      addin/installv2.sh
  6. 89 0
      addin/upgrade.sh

+ 2 - 1
CMakeLists.txt

@@ -572,7 +572,6 @@ message("Generated env.ini file in ${CMAKE_BINARY_DIR}")
 
 # Configure files
 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ChangeLog.in" ${CMAKE_BINARY_DIR}/ChangeLog @ONLY)
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/addin/Run.ini.in" "${CMAKE_BINARY_DIR}/Run.ini" @ONLY NEWLINE_STYLE CRLF)
 
 if(SIMULATE_ON)
 	if(EXISTS "${RVC_INSTALL_PREFIX}${CMAKE_INSTALL_BINDIR}" AND IS_DIRECTORY "${RVC_INSTALL_PREFIX}${CMAKE_INSTALL_BINDIR}")
@@ -731,6 +730,8 @@ endif(MSVC)
 # TODO: rewrite install.sh to match update pacakge.
 if(NOT MSVC AND NOT PACK_AS_DEB_PKG)
 	install(PROGRAMS "${CMAKE_SOURCE_DIR}/addin/install.sh" DESTINATION "${PACK_INSTALL_RUN_DIR}/./.." COMPONENT scripts)
+	install(PROGRAMS "${CMAKE_SOURCE_DIR}/addin/upgrade.sh" DESTINATION "${PACK_INSTALL_RUN_DIR}/./.." COMPONENT scripts)
+	install(FILES "${CMAKE_SOURCE_DIR}/addin/Readme.txt" DESTINATION "${PACK_INSTALL_RUN_DIR}/./.." COMPONENT scripts)
 endif(NOT MSVC AND NOT PACK_AS_DEB_PKG)
 
 list(REMOVE_DUPLICATES RVC_CONAN_DEP_LIBS)

+ 6 - 0
addin/Readme.txt

@@ -0,0 +1,6 @@
+install.sh 用于全新安装版本场景
+upgrade.sh 用于更新版本的场景
+
+根据需求,二者选其一
+均需使用 root 权限运行
+请用命令行执行 ‘sudo bash ./install.sh’或 ‘sudo bash ./upgrade.sh’

+ 0 - 25
addin/Run.ini.in

@@ -1,25 +0,0 @@
-[Precondition]
-MachineType=RVC.Stand2S
-MachineVersion=5.0
-SoftwareVersion=0.0.0-@RVC_FRAMEWORK_VERSION@
-OSVersion=4.0-
-Device=
-Depend=
-Cover=
-
-[Action]
-;UpgradeVersion:A表示自动升级版本号;也可以指定版本,为空表示轻量升级
-UpgradeVersion=@RVC_FRAMEWORK_VERSION@
-;待删除文件列表
-;ToDelete=
-
-
-;待拷贝文件列表,必须为Run或Data子目录,如:Run\bin\*.exe,Run\bin\*.dll,Run\mod\*.dll,Run\dep\*.dll,Run\cfg\*.ini,Run\cfg\*.*
-ToCopy=Run\dep\*,Run\bin\*,Run\mod\*.*,Run\cfg\*.*,Run\res\*
-
-;待运行文件列表,适用于系统外升级
-;ToRun=
-
-;CopyMode拷贝模式:1(存在才拷贝并覆盖)|2(不存在才拷贝)|3(强制拷贝)|4(存在不拷贝)
-;[test20140422.txt]
-CopyMode=3

+ 273 - 30
addin/install.sh

@@ -5,25 +5,221 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`"  # absolutized and normalized
 
 
 echo "[RVCTermianal] === Install Start === "
+curr_timestamp=`date "+%Y%m%d-%H%M%S.%3N"`
+lightdm_file=/etc/lightdm/lightdm.conf
 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
+res=0
 
-#detect the usr input the vendor or not
-has_vendor=0
-tolower_vendor=''
-upper_vendor=''
+#设置开机自动登录用户(有做冗余判断)
+setup_autologin()
+{
+    given_user=$1
+    given_sudoers_file=$2
+
+    if [ ! -f "$given_sudoers_file" ]; then
+        echo "[Seat:*]" > $given_sudoers_file
+        # echo "autologin-guest=false" >> $given_sudoers_file
+        echo "autologin-user=$given_user" >> $given_sudoers_file
+        echo "autologin-user-timeout=0" >> $given_sudoers_file
+    fi
+
+    if [ "$(grep -c "^\\s*autologin-user=${given_user}" $given_sudoers_file)" -gt 0 ]; then
+        echo "autologin-user is already setted in ^lightdm.conf^"
+    else
+        echo "setting autologin-user in ^$given_sudoers_file^"
+        #sed -i.bak -E "s|^#(autologin-user=).*|\\1$given_user|;s|^#(autologin-user-timeout=).*|\\0|" $given_sudoers_file
+        sed -i "s/^\s*#\s*autologin-user=/autologin-user=/g;s/autologin-user=.*$/autologin-user=$given_user/g" $given_sudoers_file
+        #sed -i "s/^#autologin-user=$/autologin-user=${given_user}/" $given_sudoers_file
+        #sed -i "s/^#autologin-user-timeout=$/autologin-user-timeout=0/" $given_sudoers_file
+        sed -i "s/^\s*#\s*autologin-user-timeout=/autologin-user-timeout=/g;s/autologin-user-timeout=.*$/autologin-user-timeout=0/g" $given_sudoers_file
+    fi
+}
+
+#设置免密使用root权限(有做冗余判断)
+sudo_priviledge() 
+{
+
+    given_user=$1
+    given_sudoers_file=$2
+
+    if [ -e ${given_sudoers_file}.tmp -o "$(pidof visudo)" ]; then
+        echo "[ERROR]: ${given_sudoers_file} is working now,  wait a little and then try again later"
+        return 2
+    fi
+
+    ret=0
+	echo "[INFO]: to process editing sudoers file..."
+	cp ${given_sudoers_file} ${given_sudoers_file}.tmp
+    chmod 0640 ${given_sudoers_file}.tmp
+    cat ${given_sudoers_file}.tmp | grep  'includedir /etc/sudoers.d' > /dev/null
+    if [ $? = 0 ]; then
+        echo "[INFO]: '#includedir /etc/sudoers.d' already exists in /etc/sudoers file"
+    else
+        echo "#includedir /etc/sudoers.d"  >> ${given_sudoers_file}.tmp
+        ret=1
+    fi
+
+	if [  "`cat /etc/sudoers | grep ${given_user} | grep ALL=\(ALL\)`" != "" ]; then
+        echo "[WARN]: sudoers file has been loaded up all(all) config"
+    else
+        new_entry="${given_user} ALL=(ALL) ALL"
+        echo "${new_entry}" >> ${given_sudoers_file}.tmp
+        ret=1
+    fi
+
+    if [  "`cat /etc/sudoers|grep ${given_user}|grep Run`" != "" ]; then
+        echo "[WARN]: sudoers file has been loaded up rvc config"
+    else
+        new_entry="${given_user} ALL=(ALL) NOPASSWD: /opt/Run/version/*, NOPASSWD: /bin/sh, NOPASSWD: /bin/bash"
+        echo "${new_entry}" >> ${given_sudoers_file}.tmp
+        ret=1
+    fi
+
+    chmod 0440 ${given_sudoers_file}.tmp
+
+    if visudo -c -f ${given_sudoers_file}.tmp ; then
+        echo check syntax correct on ${given_sudoers_file}.tmp
+    else
+        echo "[ERROR]: syntax check failed on file ${given_sudoers_file}"
+        rm ${given_sudoers_file}.tmp
+		#if [ -f "${given_sudoers_file}.backup" ]; then
+		#fi
+        return 3
+    fi
+
+    if [ $ret -eq 1 ]; then
+        echo "[SUCCESS]: config file has been change !!"
+        cp ${given_sudoers_file} ${given_sudoers_file}.backup
+        mv ${given_sudoers_file}.tmp ${given_sudoers_file}
+        ret=0
+    else
+        echo "[WARN]: config file not change"
+        rm ${given_sudoers_file}.tmp
+        ret=0
+    fi
+
+    return $ret
+}
+
+# check root priviledge
+if [ $(id -u) != 0 ]; then
+    echo "[ERROR] === 该安装脚本需要以ROOT权限启动,请在命令行窗口添加sudo指令执行,比如 'sudo bash $0' ==="
+    exit 0
+fi
+
+argument1=
 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) }' )
+	argument1=$(echo $1 | awk '{ print tolower($0) }' )
+else
+    echo no any arguments.
+fi
+
+#获取当前登录的用户名称,这里可以考虑用另外一种优化的方法
+rvc_user=$USER
+if [ -z "$rvc_user" -o "$rvc_user" = "root" ]; then
+	users=$(cat /etc/passwd | awk -F: '$3>=500' | cut -f 1 -d :)
+	echo "user list: $users"
+	cnt=0
+	for var in $(echo ${users} | awk '{split($0,arr,",");for(i in arr) print arr[i]}')
+	do
+		if [ ${var} != 'nobody' -a ${var} != 'systemd-coredump' -a ${var} != 'liuwt' -a ${var} != 'deepin-anything-server' ]; then
+			cnt=$((${cnt}+1))
+			rvc_user=${var}
+		fi
+	done
+	if [ $cnt -ne 1 ]; then
+		echo "too many users: $cnt"
+		rvc_user=''
+	else
+		echo "aim user: $rvc_user"
+	fi
+fi
+
+#上保险
+if [ -z "$rvc_user" ]; then
+	name=$(whoami)
+	exec="bash $ABS_CURRENT_PATH/sub_install_user.sh"
+	pid=$(pgrep startdde)
+	. <(xargs -0 bash -c 'printf "export %q\n" "$@"' -- </proc/$pid/environ)
+	name=$(ps -o uname= -p "${pid}")
+	echo new fetch name: $name
+	rvc_user=$name
+fi
+
+if [ "$argument1" = "uninstall" ]; then
+	rm /etc/xdg/autostart/spexplorerauto.desktop > /dev/null 2>&1
+    rm /usr/share/applications/spexplorerauto.desktop > /dev/null 2>&1
+    rm -rf /opt/rvc > /dev/null 2>&1
+    rm -rf /opt/Run > /dev/null 2>&1
+    rm -rf /opt/wlog > /dev/null 2>&1
+
+    echo "[INFO]: set menu tool as show mode..."
+    gsettings set com.deepin.dde.dock hide-mode  keep-showing
+    echo "[INFO]: set menu tool as show mode done!"
+	
+	papers_dir=/usr/share/wallpapers/deepin
+    papers_bak_dir=/usr/share/wallpapers/deepin_bak
+    if [ -d $papers_bak_dir ]; then
+        rm -rf $papers_dir/*  > /dev/null 2>&1
+        cp $papers_bak_dir/* $papers_dir
+		rm -rf $papers_bak_dir
+    fi
+	
+	if [ -z "$rvc_user" ]; then
+		echo "[ERROR]: username is empty, please find more details"
+		exit 1
+	elif [ "$rvc_user" = "root" ]; then
+		echo "[ERROR]: username is invalid, please find more details"
+		exit 2
+	fi
+    rm /home/$rvc_user/Desktop/spexplorerauto.desktop > /dev/null 2>&1
+	exit 0
+fi
+
+
+if [ "$argument1" = "pure" ]; then
+    killall -9 spshell > /dev/null 2>&1
+    killall -9 sphost > /dev/null 2>&1
+    killall -9 guardian > /dev/null 2>&1
+    killall -9 uosbrowser > /dev/null 2>&1
+    killall -s 9 `ps -aux | grep browser | awk '{print $2}'` > /dev/null 2>&1
+fi
+
+echo "============== previous installation custom scripts start =============="
+user1=$(ps -o user= -p $$ | awk '{print $1}')
+echo "user1: $user1"
+user2=$(whoami)
+echo "user2: $user2"
+#user3=$(logname)
+#echo "user3: $user3"
+
+# 备份壁纸
+papers_dir=/usr/share/wallpapers/deepin
+papers_bak_dir=/usr/share/wallpapers/deepin_bak
+
+if [ -f "${papers_dir}/WallPaper1920.png" ]; then
+	echo "[INFO]: CMB WallPaper has been exist, skip latter copy procedure"
 else
-    echo no any arguments indicate vendor name.
+	if [ ! -d $papers_bak_dir ]; then
+		mkdir -p ${papers_bak_dir}
+		cp $papers_dir/* $papers_bak_dir
+	fi
+	rm -rf $papers_dir/* > /dev/null 2>&1
+	cp ${rvc_install_path_rvc_dir}/Resources/WallPaper1280.png ${papers_dir}
+	cp ${rvc_install_path_rvc_dir}/Resources/WallPaper1920.png ${papers_dir}
 fi
 
+echo "============== previous installation custom scripts done =============="
+
+
+echo "============== during installation custom scripts start =============="
+#拷贝终端版本
+
 # fetch the version full path at pkg
 version_dir=$(find ${MY_PATH}/Run/version/ -maxdepth 1 -regex ".*[0-9\.]$" -type d)
 echo version dir: $version_dir
@@ -31,17 +227,17 @@ slen=${#MY_PATH}
 rel_version_dir=${version_dir:$slen+1}
 echo ${rel_version_dir}
 
+# 如果版本中有root.ini,移除测试的root.ini文件
+if [ -f ${MY_PATH}/Run/hardwarecfg/root.ini ]; then
+	sudo rm ${MY_PATH}/Run/hardwarecfg/root.ini
+fi
+if [ -d ${MY_PATH}/Run/runinfo ]; then
+	sudo rm -rf ${MY_PATH}/Run/runinfo
+fi
+
 if [ ! -f $rvc_install_path_hardware_dir/root.ini ]; then
     #delete /opt/Run
     sudo rm -rf ${rvc_install_path_Run_dir}
-else
-    echo root.ini 文件已存在,跳过清除 Run 文件夹.
-    if [ -f ${MY_PATH}/Run/hardwarecfg/root.ini ]; then
-        sudo rm ${MY_PATH}/Run/hardwarecfg/root.ini
-    fi
-    if [ -d ${MY_PATH}/Run/runinfo ]; then
-        sudo rm -rf ${MY_PATH}/Run/runinfo
-    fi
 fi
 
 #copy the Run pkg to run path
@@ -59,10 +255,10 @@ if [ ! -d $rvc_install_path_rvc_dir/adData ]; then
 fi
 sudo cp -rvf $MY_PATH/rvc/adData/Audio ${rvc_install_path_rvc_dir}/adData
 echo copy rvc Audio files completely!
-sudo cp -rvf $MY_PATH/rvc/adData/Video ${rvc_install_path_rvc_dir}/adData
-echo copy rvc Video files completely!
+#sudo cp -rvf $MY_PATH/rvc/adData/Video ${rvc_install_path_rvc_dir}/adData
+#echo copy rvc Video files completely!
 
-echo change the run scripts priviledge...
+echo "[INFO]: change the run scripts priviledge..."
 echo ${rvc_install_path_rvc_dir}
 echo ${rvc_install_path_root}/${rel_version_dir}
 sudo chmod 777 ${rvc_install_path_root}
@@ -72,18 +268,65 @@ 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
 sudo chmod a+rw ${rvc_install_path_versions_dir}/active.txt
-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-Stand2S-G1-$tolower_vendor.ini
-    if [ -f $root_vendor_file -a ! -f $root_files ] #  ! -f $root_file -a 
-    then
-        echo "重命名 root.ini "
-        sudo cp $root_vendor_file $root_file
-    fi
+echo "[INFO]: change the run scripts priviledge done!"
+
+echo "============== during installation custom scripts done =============="
+
+echo "============== post installation custom scripts start =============="
+
+sudoers_file=/etc/sudoers
+if [ -z "$rvc_user" ]; then
+	echo "[ERROR]: username is empty, please find more details"
+	exit 1
+elif [ "$rvc_user" = "root" ]; then
+	echo "[ERROR]: username is invalid, please find more details"
+	exit 2
+fi
+
+echo "[INFO]: Going to add entry into /etc/sudoers file for user: $rvc_user"
+
+if [ ! -d '/etc/sudoers.d' ]; then
+	mkidr /etc/sudoers.d
+	chmod 750 /etc/sudoers.d
+fi
+
+sudo_priviledge ${rvc_user}   ${sudoers_file}
+res=$?
+if [ $res -eq 0 ]; then
+
+	# 清理桌面数据
+	echo "[INFO]: rm file under desktop directory..."
+	rm -rf /home/$rvc_user/Desktop/* > /dev/null 2>&1
+	echo "[INFO]: rm file under desktop directory done!"
+
+	echo "[INFO]: setup user $rvc_user auto login.." 
+	setup_autologin  ${rvc_user}   ${lightdm_file}
+	
+	#设置桌面图标,
+	echo "[INFO]: Copy application icon to menu tools..."
+	cp /opt/rvc/Resources/spexplorerauto.desktop /usr/share/applications
+	echo "[INFO]: Active application icon autorun after boot..."
+	cp /opt/rvc/Resources/spexplorerauto.desktop /etc/xdg/autostart/
+	echo "[INFO]: Copy application icon to desktop..."
+	cp /opt/rvc/Resources/spexplorerauto.desktop /home/$rvc_user/Desktop
+fi
+
+#去掉密钥环,之前出现过这种问题,统信指示移除该文件即可
+keyring_file=/home/$rvc_user/.local/share/keyrings/login.keyring
+if [ -f "$keyring_file" ]; then
+	rm $keyring_file
+	echo "[INFO]: remove keyring file."
 fi
 
-echo "[RVCTermianal] === Install Done ! === "
+# 设置隐藏菜单栏
+echo "[INFO]: set menu tool as hidden mode..."
+gsettings set com.deepin.dde.dock hide-mode  keep-hidden
+echo "[INFO]: set menu tool as hidden mode done!"
+
+echo "============== post installation custom scripts done =============="
+
+if [ "$argument1" = "pure" ]; then
+    sudo ${rvc_install_path_versions_dir}/spexplorer.sh
+fi
 
 exit 0

+ 0 - 321
addin/installv2.sh

@@ -1,321 +0,0 @@
-#!/bin/bash
-MY_PATH="`dirname \"$0\"`"              # relative
-# echo "1"$MY_PATH
-MY_PATH="`( cd \"$MY_PATH\" && pwd )`"  # absolutized and normalized
-
-
-echo "[RVCTermianal] === Install Start === "
-curr_timestamp=`date "+%Y%m%d-%H%M%S.%3N"`
-lightdm_file=/etc/lightdm/lightdm.conf
-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
-res=0
-
-#设置开机自动登录用户(有做冗余判断)
-setup_autologin()
-{
-    given_user=$1
-    given_sudoers_file=$2
-
-    if [ ! -f "$given_sudoers_file" ]; then
-        echo "[Seat:*]" > $given_sudoers_file
-        # echo "autologin-guest=false" >> $given_sudoers_file
-        echo "autologin-user=$given_user" >> $given_sudoers_file
-        echo "autologin-user-timeout=0" >> $given_sudoers_file
-    fi
-
-    if [ "$(grep -c "^\\s*autologin-user=${given_user}" $given_sudoers_file)" -gt 0 ]; then
-        echo "autologin-user is already setted in ^lightdm.conf^"
-    else
-        echo "setting autologin-user in ^$given_sudoers_file^"
-        #sed -i.bak -E "s|^#(autologin-user=).*|\\1$given_user|;s|^#(autologin-user-timeout=).*|\\0|" $given_sudoers_file
-        sed -i "s/^\s*#\s*autologin-user=/autologin-user=/g;s/autologin-user=.*$/autologin-user=$given_user/g" $given_sudoers_file
-        #sed -i "s/^#autologin-user=$/autologin-user=${given_user}/" $given_sudoers_file
-        #sed -i "s/^#autologin-user-timeout=$/autologin-user-timeout=0/" $given_sudoers_file
-        sed -i "s/^\s*#\s*autologin-user-timeout=/autologin-user-timeout=/g;s/autologin-user-timeout=.*$/autologin-user-timeout=0/g" $given_sudoers_file
-    fi
-}
-
-#设置免密使用root权限(有做冗余判断)
-sudo_priviledge() 
-{
-
-    given_user=$1
-    given_sudoers_file=$2
-
-    if [ -e ${given_sudoers_file}.tmp -o "$(pidof visudo)" ]; then
-        echo "[ERROR]: ${given_sudoers_file} is working now,  wait a little and then try again later"
-        return 2
-    fi
-
-    ret=0
-	echo "[INFO]: to process editing sudoers file..."
-	cp ${given_sudoers_file} ${given_sudoers_file}.tmp
-    chmod 0640 ${given_sudoers_file}.tmp
-    cat ${given_sudoers_file}.tmp | grep  'includedir /etc/sudoers.d' > /dev/null
-    if [ $? = 0 ]; then
-        echo "[INFO]: '#includedir /etc/sudoers.d' already exists in /etc/sudoers file"
-    else
-        echo "#includedir /etc/sudoers.d"  >> ${given_sudoers_file}.tmp
-        ret=1
-    fi
-
-	if [  "`cat /etc/sudoers|grep ${given_user}|grep ALL=(ALL)`" != "" ]; then
-        echo "[WARN]: sudoers file has been loaded up all(all) config"
-    else
-        new_entry="${given_user} ALL=(ALL) ALL"
-        echo "${new_entry}" >> ${given_sudoers_file}.tmp
-        ret=1
-    fi
-
-    if [  "`cat /etc/sudoers|grep ${given_user}|grep Run`" != "" ]; then
-        echo "[WARN]: sudoers file has been loaded up rvc config"
-    else
-        new_entry="${given_user} ALL=(ALL) NOPASSWD: /opt/Run/version/*, NOPASSWD: /bin/sh, NOPASSWD: /bin/bash"
-        echo "${new_entry}" >> ${given_sudoers_file}.tmp
-        ret=1
-    fi
-
-    chmod 0440 ${given_sudoers_file}.tmp
-
-    if visudo -c -f ${given_sudoers_file}.tmp ; then
-        echo check syntax correct on ${given_sudoers_file}.tmp
-    else
-        echo "[ERROR]: syntax check failed on file ${given_sudoers_file}"
-        rm ${given_sudoers_file}.tmp
-		#if [ -f "${given_sudoers_file}.backup" ]; then
-		#fi
-        return 3
-    fi
-
-    if [ $ret -eq 1 ]; then
-        echo "[SUCCESS]: config file has been change !!"
-        cp ${given_sudoers_file} ${given_sudoers_file}.backup
-        mv ${given_sudoers_file}.tmp ${given_sudoers_file}
-        ret=0
-    else
-        echo "[WARN]: config file not change"
-        rm ${given_sudoers_file}.tmp
-        ret=0
-    fi
-
-    return $ret
-}
-
-# check root priviledge
-if [ $(id -u) != 0 ]; then
-    echo "[ERROR] === it requires root priviledge to run this shell scripts, please use 'sudo bash ./$0' ==="
-    exit 0
-fi
-
-argument1=
-if [ $# -eq 1 ];then
-    echo has arguments: $*
-	argument1=$(echo $1 | awk '{ print tolower($0) }' )
-else
-    echo no any arguments.
-fi
-
-#获取当前登录的用户名称,这里可以考虑用另外一种优化的方法
-rvc_user=$USER
-if [ -z "$rvc_user" -o "$rvc_user" = "root" ]; then
-	users=$(cat /etc/passwd | awk -F: '$3>=500' | cut -f 1 -d :)
-	echo "user list: $users"
-	cnt=0
-	for var in $(echo ${users} | awk '{split($0,arr,",");for(i in arr) print arr[i]}')
-	do
-		if [ ${var} != 'nobody' -a ${var} != 'systemd-coredump' -a ${var} != 'liuwt' -a ${var} != 'deepin-anything-server' ]; then
-			cnt=$((${cnt}+1))
-			rvc_user=${var}
-		fi
-	done
-	if [ $cnt -ne 1 ]; then
-		echo "too many users: $cnt"
-		rvc_user=''
-	else
-		echo "aim user: $rvc_user"
-	fi
-fi
-
-if [ "$argument1" = "uninstall" ]; then
-	rm /etc/xdg/autostart/spexplorerauto.desktop > /dev/null 2>&1
-    rm /usr/share/applications/spexplorerauto.desktop > /dev/null 2>&1
-    rm -rf /opt/rvc > /dev/null 2>&1
-    rm -rf /opt/Run > /dev/null 2>&1
-    rm -rf /opt/wlog > /dev/null 2>&1
-
-    echo "[INFO]: set menu tool as show mode..."
-    gsettings set com.deepin.dde.dock hide-mode  keep-showing
-    echo "[INFO]: set menu tool as show mode done!"
-	
-	papers_dir=/usr/share/wallpapers/deepin
-    papers_bak_dir=/usr/share/wallpapers/deepin_bak
-    if [ -d $papers_bak_dir ]; then
-        rm -rf $papers_dir/*  > /dev/null 2>&1
-        cp $papers_bak_dir/* $papers_dir
-		rm -rf $papers_bak_dir
-    fi
-	
-	if [ -z "$rvc_user" ]; then
-		echo "[ERROR]: username is empty, please find more details"
-		exit 1
-	elif [ "$rvc_user" = "root" ]; then
-		echo "[ERROR]: username is invalid, please find more details"
-		exit 2
-	fi
-    rm /home/$rvc_user/Desktop/spexplorerauto.desktop > /dev/null 2>&1
-	exit 0
-fi
-
-
-if [ "$argument1" = "pure" ]; then
-    killall -9 spshell > /dev/null 2>&1
-    killall -9 sphost > /dev/null 2>&1
-    killall -9 guardian > /dev/null 2>&1
-    killall -9 uosbrowser > /dev/null 2>&1
-    killall -s 9 `ps -aux | grep browser | awk '{print $2}'` > /dev/null 2>&1
-fi
-
-echo "============== previous installation custom scripts start =============="
-user1=$(ps -o user= -p $$ | awk '{print $1}')
-echo "user1: $user1"
-user2=$(whoami)
-echo "user2: $user2"
-#user3=$(logname)
-#echo "user3: $user3"
-
-# 备份壁纸
-papers_dir=/usr/share/wallpapers/deepin
-papers_bak_dir=/usr/share/wallpapers/deepin_bak
-
-if [ -f "${papers_dir}/WallPaper1920.png" ]; then
-	echo "[INFO]: CMB WallPaper has been exist, skip latter copy procedure"
-else
-	if [ ! -d $papers_bak_dir ]; then
-		mkdir -p ${papers_bak_dir}
-		cp $papers_dir/* $papers_bak_dir
-	fi
-	rm -rf $papers_dir/* > /dev/null 2>&1
-	cp ${rvc_install_path_rvc_dir}/Resources/WallPaper1280.png ${papers_dir}
-	cp ${rvc_install_path_rvc_dir}/Resources/WallPaper1920.png ${papers_dir}
-fi
-
-echo "============== previous installation custom scripts done =============="
-
-
-echo "============== during installation custom scripts start =============="
-#拷贝终端版本
-
-# fetch the version full path at pkg
-version_dir=$(find ${MY_PATH}/Run/version/ -maxdepth 1 -regex ".*[0-9\.]$" -type d)
-echo version dir: $version_dir
-slen=${#MY_PATH}
-rel_version_dir=${version_dir:$slen+1}
-echo ${rel_version_dir}
-
-# 如果版本中有root.ini,移除测试的root.ini文件
-if [ -f ${MY_PATH}/Run/hardwarecfg/root.ini ]; then
-	sudo rm ${MY_PATH}/Run/hardwarecfg/root.ini
-fi
-if [ -d ${MY_PATH}/Run/runinfo ]; then
-	sudo rm -rf ${MY_PATH}/Run/runinfo
-fi
-
-if [ ! -f $rvc_install_path_hardware_dir/root.ini ]; then
-    #delete /opt/Run
-    sudo rm -rf ${rvc_install_path_Run_dir}
-fi
-
-#copy the Run pkg to run path
-echo to copy Run package...
-sudo cp -rvf $MY_PATH/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
-if [ ! -d $rvc_install_path_rvc_dir/adData ]; then
-    sudo mkdir -p ${rvc_install_path_rvc_dir}/adData
-fi
-sudo cp -rvf $MY_PATH/rvc/adData/Audio ${rvc_install_path_rvc_dir}/adData
-echo copy rvc Audio files completely!
-#sudo cp -rvf $MY_PATH/rvc/adData/Video ${rvc_install_path_rvc_dir}/adData
-#echo copy rvc Video files completely!
-
-echo "[INFO]: change the run scripts priviledge..."
-echo ${rvc_install_path_rvc_dir}
-echo ${rvc_install_path_root}/${rel_version_dir}
-sudo chmod 777 ${rvc_install_path_root}
-sudo chmod a+rw -R ${rvc_install_path_rvc_dir}
-sudo chmod a+rw -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
-sudo chmod a+rw ${rvc_install_path_versions_dir}/active.txt
-echo "[INFO]: change the run scripts priviledge done!"
-
-echo "============== during installation custom scripts done =============="
-
-echo "============== post installation custom scripts start =============="
-
-sudoers_file=/etc/sudoers
-if [ -z "$rvc_user" ]; then
-	echo "[ERROR]: username is empty, please find more details"
-	exit 1
-elif [ "$rvc_user" = "root" ]; then
-	echo "[ERROR]: username is invalid, please find more details"
-	exit 2
-fi
-
-echo "[INFO]: Going to add entry into /etc/sudoers file for user: $rvc_user"
-
-if [ ! -d '/etc/sudoers.d' ]; then
-	mkidr /etc/sudoers.d
-	chmod 750 /etc/sudoers.d
-fi
-
-sudo_priviledge ${rvc_user}   ${sudoers_file}
-res=$?
-if [ $res -eq 0 ]; then
-
-	# 清理桌面数据
-	echo "[INFO]: rm file under desktop directory..."
-	rm -rf /home/$rvc_user/Desktop/* > /dev/null 2>&1
-	echo "[INFO]: rm file under desktop directory done!"
-
-	echo "[INFO]: setup user $rvc_user auto login.." 
-	setup_autologin  ${rvc_user}   ${lightdm_file}
-	
-	#设置桌面图标,
-	echo "[INFO]: Copy application icon to menu tools..."
-	cp /opt/rvc/Resources/spexplorerauto.desktop /usr/share/applications
-	echo "[INFO]: Active application icon autorun after boot..."
-	cp /opt/rvc/Resources/spexplorerauto.desktop /etc/xdg/autostart/
-	echo "[INFO]: Copy application icon to desktop..."
-	cp /opt/rvc/Resources/spexplorerauto.desktop /home/$rvc_user/Desktop
-fi
-
-#去掉密钥环,之前出现过这种问题,统信指示移除该文件即可
-keyring_file=/home/$rvc_user/.local/share/keyrings/login.keyring
-if [ -f "$keyring_file" ]; then
-	rm $keyring_file
-	echo "[INFO]: remove keyring file."
-fi
-
-# 设置隐藏菜单栏
-echo "[INFO]: set menu tool as hidden mode..."
-gsettings set com.deepin.dde.dock hide-mode  keep-hidden
-echo "[INFO]: set menu tool as hidden mode done!"
-
-echo "============== post installation custom scripts done =============="
-
-if [ "$argument1" = "pure" ]; then
-    sudo ${rvc_install_path_versions_dir}/spexplorer.sh
-fi
-
-exit 0

+ 89 - 0
addin/upgrade.sh

@@ -0,0 +1,89 @@
+#!/bin/bash
+MY_PATH="`dirname \"$0\"`"              # relative
+# echo "1"$MY_PATH
+MY_PATH="`( cd \"$MY_PATH\" && pwd )`"  # absolutized and normalized
+
+
+echo "[RVCTermianal] === Install Start === "
+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 indicate vendor name.
+fi
+
+# fetch the version full path at pkg
+version_dir=$(find ${MY_PATH}/Run/version/ -maxdepth 1 -regex ".*[0-9\.]$" -type d)
+echo version dir: $version_dir
+slen=${#MY_PATH}
+rel_version_dir=${version_dir:$slen+1}
+echo ${rel_version_dir}
+
+if [ ! -f $rvc_install_path_hardware_dir/root.ini ]; then
+    #delete /opt/Run
+    sudo rm -rf ${rvc_install_path_Run_dir}
+else
+    echo root.ini 文件已存在,跳过清除 Run 文件夹.
+    if [ -f ${MY_PATH}/Run/hardwarecfg/root.ini ]; then
+        sudo rm ${MY_PATH}/Run/hardwarecfg/root.ini
+    fi
+    if [ -d ${MY_PATH}/Run/runinfo ]; then
+        sudo rm -rf ${MY_PATH}/Run/runinfo
+    fi
+fi
+
+#copy the Run pkg to run path
+echo to copy Run package...
+sudo cp -rvf $MY_PATH/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
+if [ ! -d $rvc_install_path_rvc_dir/adData ]; then
+    sudo mkdir -p ${rvc_install_path_rvc_dir}/adData
+fi
+sudo cp -rvf $MY_PATH/rvc/adData/Audio ${rvc_install_path_rvc_dir}/adData
+echo copy rvc Audio files completely!
+sudo cp -rvf $MY_PATH/rvc/adData/Video ${rvc_install_path_rvc_dir}/adData
+echo copy rvc Video files completely!
+
+echo change the run scripts priviledge...
+echo ${rvc_install_path_rvc_dir}
+echo ${rvc_install_path_root}/${rel_version_dir}
+sudo chmod 777 ${rvc_install_path_root}
+sudo chmod a+rw -R ${rvc_install_path_rvc_dir}
+sudo chmod a+rw -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
+sudo chmod a+rw ${rvc_install_path_versions_dir}/active.txt
+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-Stand2S-G1-$tolower_vendor.ini
+    if [ -f $root_vendor_file -a ! -f $root_files ] #  ! -f $root_file -a 
+    then
+        echo "重命名 root.ini "
+        sudo cp $root_vendor_file $root_file
+    fi
+fi
+
+echo "[RVCTermianal] === Install Done ! === "
+
+exit 0