|
@@ -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
|