Преглед на файлове

Bash Fixes for Some Picky Systems

own3mall преди 9 години
родител
ревизия
decd28b264
променени са 3 файла, в които са добавени 8 реда и са изтрити 3 реда
  1. 3 1
      includes/ogp_agent.init.dbn
  2. 4 1
      includes/ogp_agent.init.rh
  3. 1 1
      ogp_agent_run

+ 3 - 1
includes/ogp_agent.init.dbn

@@ -51,7 +51,9 @@ start() {
 		usermod -aG sudo $agent_user >/dev/null 2>&1
 	fi
 
-	chown -Rf `id -u $agent_user`:`id -g $agent_user` $agent_dir >/dev/null 2>&1
+	# Had to add the "|| true" part to the end of the below command due to chown causing the entire bash script to exit on failure in case of protected files (that have chattr +i applied)
+	# http://unix.stackexchange.com/questions/118217/chmod-silent-mode-how-force-exit-code-0-in-spite-of-error
+	chown -Rf `id -u $agent_user`:`id -g $agent_user` $agent_dir >/dev/null 2>&1 || true
 
 	# Lets the agent user to attach screens.
 	if [ "$( groups $agent_user | grep "\btty\b" )" == "" ]

+ 4 - 1
includes/ogp_agent.init.rh

@@ -61,7 +61,10 @@ start() {
 	fi
 	
 	group=`groups $agent_user | awk '{ print $3 }'`; 
-	chown -Rf $agent_user:$group $agent_dir &> /dev/null
+	
+	# Had to add the "|| true" part to the end of the below command due to chown causing the entire bash script to exit on failure in case of protected files (that have chattr +i applied)
+	# http://unix.stackexchange.com/questions/118217/chmod-silent-mode-how-force-exit-code-0-in-spite-of-error
+	chown -Rf $agent_user:$group $agent_dir &> /dev/null || true
 	
 	# Lets the agent user to attach screens.
 	if [ "$( groups $agent_user | grep "\btty\b" )" == "" ]

+ 1 - 1
ogp_agent_run

@@ -41,7 +41,7 @@ if test `id -u` -eq 0; then
 fi
 
 getSudoPassword(){
-	sudoPass=$(cat "$AGENTDIR/Cfg/Config.pm" | grep -o "sudo_password.*" | grep -o "[^sudo_password( )*=>( )*'].*" | grep -o ".*[^',]")
+	sudoPass=$(cat "$AGENTDIR/Cfg/Config.pm" | grep -o "sudo_password.*" | grep -ow "[^sudo_password( \)*=>( \)*].*" | grep -o "[^'].*[^',]")
 }
 
 detectSystemD(){