[Blends-commit] [SCM] ezgo branch, ezgo12, updated. 3a3417b3bedf21f1e3dc7aeb18b6a3a552e48238

Franklin franklin at goodhorse.idv.tw
Thu Jul 2 03:18:20 UTC 2015


The following commit has been merged in the ezgo12 branch:
commit 3a3417b3bedf21f1e3dc7aeb18b6a3a552e48238
Author: Franklin <franklin at goodhorse.idv.tw>
Date:   Thu Jul 2 11:17:33 2015 +0800

    Add recover shell script and desktop file back

diff --git a/debian/ezgo-misc.install b/debian/ezgo-misc.install
index a990fee..93892eb 100644
--- a/debian/ezgo-misc.install
+++ b/debian/ezgo-misc.install
@@ -23,3 +23,5 @@ ezgo-misc/freedesktop.org.xml usr/share/ezgo/ezgo-misc/
 ezgo-misc/translations/* usr/share/ezgo/ezgo-misc/translations
 ezgo-misc/ktuberling/zh_TW/* usr/share/kde4/apps/ktuberling/sounds/zh_TW/
 ezgo-misc/ktuberling/* usr/share/kde4/apps/ktuberling/sounds/
+ezgo-misc/back.sh usr/share/ezgo/recover
+ezgo-misc/skel.sh usr/share/ezgo/recover
diff --git a/ezgo-misc/back.sh b/ezgo-misc/back.sh
new file mode 100755
index 0000000..72fdbbe
--- /dev/null
+++ b/ezgo-misc/back.sh
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+
+function user() {
+	rm /dev/shm/ezgo
+	UID_MIN=`cat /etc/login.defs | egrep "^UID_MIN" | gawk ' { print $2; } '`
+	UID_MAX=`cat /etc/login.defs | egrep "^UID_MAX" | gawk ' { print $2; } '`
+
+	while read myLine
+	do
+		TMP1=${myLine/:/ }
+		TMP2=${TMP1/:/ }
+		TMP3=${TMP2/:/ }
+		TMP4=${TMP3/:/ }
+		USERNAME=`echo $TMP4 | gawk ' { print $1; }'`
+		USERUID=`echo $TMP4 | gawk ' { print $3; } '`
+		if [ $USERUID -ge `expr $UID_MIN - 1` ]; then
+			if [ $USERUID -le $UID_MAX ]; then
+				echo $USERNAME >>/dev/shm/ezgo
+			fi
+		fi
+	done < /etc/passwd	
+	username=$(cat /dev/shm/ezgo |tr '\n' ' ')
+}
+#zh_TW lang=([0]"系統開機還原設定" [1]"選項" [2]"請選擇您要的項目" [3]"設定開機時系統自動還原" [4]"解除開機自動還原設定" [5]"設定開機時系統自動還原" [6]"請選擇要開機還原的帳號" [7]"請選擇您要的帳號" [8]"系統備份中請稍待..." [9]"系統開機還原設定完成" [10]"解除開機自動還原設定" [11]"請選擇要開機還原的帳號" [12]"請選擇您要的帳號" [13]"解除開機自動還原設定完成"
+
+function zh_TW {
+lang=("系統開機還原設定" "選項" "請選擇您要的項目" "設定開機時系統自動還原" "解除開機自動還原設定" "設定開機時系統自動還原" "請選擇要開機還原的帳號" "請選擇您要的帳號" "系統備份中請稍待..." "系統開機還原設定完成" "解除開機自動還原設定" "請選擇要開機還原的帳號" "請選擇您要的帳號" "解除開機自動還原設定完成")
+}
+
+#en_US lang=([0]"System restore settings" [1]"Options" [2]"Please choose an option" [3]"Restore default ezgo settings at boot time" [4]"Do not restore default ezgo settings at boot time" [5]"thenSystem restore setting stored." [6]"Please choose which account to restore the default settings" [7]"Please choose an account" [8]"Running system backup.  Please wait..." [9]"System restore setting stored. " [10]"Do not restore default ezgo settings at boot time" [11]"Please choose which account to restore the default settings" [12]"Please choose an account" [13]"System restore setting stored."
+
+function en_US {
+lang=("System restore settings" "Options" "Please choose an option" "Restore default ezgo settings at boot time" "Do not restore default ezgo settings at boot time" "thenSystem restore setting stored." "Please choose which account to restore the default settings" "Please choose an account" "Running system backup.  Please wait..." "System restore setting stored. " "Do not restore default ezgo settings at boot time" "Please choose which account to restore the default settings" "Please choose an account" "System restore setting stored.")
+}
+
+locale=$(env |grep "LANG="|sed  s/LANG=//g|sed s/.UTF-8//g|sed s/.utf8//g)
+$locale;
+if [ -e /etc/ezgo ]; then
+        echo "已經有ezgo資料夾"
+  else
+       mkdir /etc/ezgo 
+  fi
+
+
+input=$(zenity --list --radiolist --text "${lang[0]}" --column="${lang[1]}" --column="${lang[2]}" 1 "${lang[3]}" 2 "${lang[4]}")
+
+if [ "$input" == "${lang[3]}" ]; then
+	user;
+        tar=$(zenity --list --text "${lang[6]}" --column="${lang[7]}" $username)		
+       	
+	case $tar in
+	         "")
+		exit 0
+	    ;;
+	    *)
+		rm -rf /home/${tar}/.kde/socket-*
+		rm -rf /home/${tar}/.kde/tmp-*
+		rm -rf /home/${tar}/.kde/cache-*
+		tar jcvpf /etc/ezgo/${tar}.tar.bz2 /home/${tar} | tee >(zenity --progress --pulsate --text="${lang[8]}"  --auto-close)
+
+		ls -a /home/${tar} |tr '\n' ' ' >/etc/ezgo/${tar}.txt           
+		echo '#!/bin/bash' > /etc/init.d/restore_${tar}.sh
+		#echo "${tar}"'=$(cat /etc/ezgo/'"${tar}"'.txt)' >>/etc/init.d/restore_"${tar}".sh
+		#echo 'cd /home/'"${tar}" >>/etc/init.d/restore_"${tar}".sh		
+		echo 'sudo rm -rf /home/'"${tar}"'/*' >>/etc/init.d/restore_${tar}.sh
+		echo 'sudo rm -rf /home/'"${tar}"'/[.a-zA-Z0-9]*' >>/etc/init.d/restore_${tar}.sh
+		echo 'sudo tar jxvpf /etc/ezgo/'"${tar}"'.tar.bz2 -C /' >>/etc/init.d/restore_${tar}.sh
+		chmod +x /etc/init.d/restore_${tar}.sh
+		cd /etc/init.d
+		sudo update-rc.d restore_${tar}.sh defaults
+		zenity --info --text "${lang[9]}"
+
+	    ;;
+	esac
+
+else 
+	if [ "$input" == "${lang[4]}" ]; then
+	ls /etc/ezgo/*.tar.bz2 |sed -e 's/\.tar\.bz2//g' |sed -e 's/[/]etc[/]ezgo[/]//g' >/dev/shm/unezgo	
+	username=$(cat /dev/shm/unezgo |tr '\n' ' ')
+    	tar=$(zenity --list --text "${lang[10]}" --column="${lang[12]}" $username)
+		
+	case ${tar} in
+	         "")
+		exit 0
+	    ;;
+	    *)
+		sudo rm /etc/ezgo/${tar}.tar.bz2
+		sudo rm /etc/ezgo/${tar}.txt		
+		sudo rm /etc/init.d/restore_${tar}.sh
+               	zenity --info --text "${lang[13]}"
+	    ;;
+	esac
+	
+	else 
+		exit 0
+
+	fi
+
+fi
+
+
diff --git a/ezgo-misc/recover.desktop b/ezgo-misc/recover.desktop
new file mode 100755
index 0000000..55cf87d
--- /dev/null
+++ b/ezgo-misc/recover.desktop
@@ -0,0 +1,21 @@
+[Desktop Entry]
+Categories=myezgo;
+Comment[zh_TW]=使用者還原設定
+Comment=User recover program
+Exec=gksudo /usr/share/ezgo/recover/back.sh
+Path=/usr/share/ezgo/recover
+GenericName[zh_TW]=還原使用者在 ezgo 下的環境設定
+GenericName=Recover user settings
+Icon=/usr/share/icons/ezgo/b2home.png
+Name[zh_TW]=使用者還原設定
+Name=Recover user settings
+StartupNotify=true
+Terminal=false
+TerminalOptions=
+Type=Application
+X-DBUS-ServiceName=
+X-DBUS-StartupType=
+X-KDE-SubstituteUID=false
+X-KDE-Username=
+desktop=recover.desktop
+
diff --git a/ezgo-misc/skel.desktop b/ezgo-misc/skel.desktop
new file mode 100755
index 0000000..d79104a
--- /dev/null
+++ b/ezgo-misc/skel.desktop
@@ -0,0 +1,20 @@
+[Desktop Entry]
+Categories=myezgo;
+Comment[zh_TW]=還原 ezgo 初始設定
+Comment=Restore default settings
+Exec=gksudo /usr/share/ezgo/recover/skel.sh
+Path=/usr/share/ezgo/recover
+GenericName[zh_TW]=將您的 ezgo 還原至安裝時的初始設定
+GenericName=Restore default settings
+Icon=/usr/share/icons/ezgo/b2ezgo.png
+Name[zh_TW]=還原 ezgo 初始設定
+Name=Restore default settings
+StartupNotify=true
+Terminal=false
+TerminalOptions=
+Type=Application
+X-DBUS-ServiceName=
+X-DBUS-StartupType=
+X-KDE-SubstituteUID=false
+X-KDE-Username=
+desktop=skel.desktop
diff --git a/ezgo-misc/skel.sh b/ezgo-misc/skel.sh
new file mode 100755
index 0000000..ec59aff
--- /dev/null
+++ b/ezgo-misc/skel.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+#LANG=zh_TW.utf8
+function zh_TW {
+lang=("將 ezgo 還原初始設定,還原完成後將會自動重新開機。您確定要進行嗎?" "確定" "取消")
+}
+
+function en_US {
+lang=("Ezgo default settings will be restored.  System will be automatically rebooted after it is done.  Are you sure?" "OK" "Cancel")
+}
+
+locale=$(env |grep "LANG="|sed  s/LANG=//g|sed s/.UTF-8//g|sed s/.utf8//g)
+$locale;
+
+
+skel=$(zenity --question --text "${lang[0]}" --ok-label="${lang[1]}" --cancel-label="${lang[2]}")
+
+if   [ $? == 0 ]; then
+	user=$(env |grep SUDO_USER= |sed -e 's/SUDO_USER=//g' )
+	rm -rf /home/$user/.bash_logout
+	rm -rf /home/$user/.bashrc
+	rm -rf /home/$user/.bash_history
+	rm -rf /home/$user/.config
+	rm -rf /home/$user/.FreeCAD
+	rm -rf /home/$user/.java
+        rm -rf /home/$user/.kde
+	rm -rf /home/$user/.local
+        rm -rf /home/$user/.macromedia
+        rm -rf /home/$user/.mozilla
+	rm -rf /home/$user/.xbmc
+	rm -rf /home/$user/.profile
+	cp -af /etc/skel/.bash_logout /home/$user
+	cp -af /etc/skel/.bashrc /home/$user
+	cp -af /etc/skel/.config /home/$user
+	cp -af /etc/skel/.FreeCAD /home/$user
+	cp -af /etc/skel/.java /home/$user
+	cp -af /etc/skel/.kde /home/$user
+	cp -af /etc/skel/.local /home/$user
+	cp -af /etc/skel/.macromedia /home/$user
+	cp -af /etc/skel/.mozilla /home/$user
+	cp -af /etc/skel/.xbmc /home/$user
+	cp -af /etc/skel/.profile /home/$user
+	chown -R $user.$user /home/$user	
+	#sudo  tar jxvpf /etc/ezgo/skel.tar -C /home/$user| tee >(zenity --progress --pulsate --text="系統還原初始設定中請稍待..."  --auto-close)
+	reboot
+elif [ $? == 1 ]; then
+	exit
+
+fi 
+

-- 
Blend for educatipn with asian specific adaptations



More information about the Blends-commit mailing list