Initial Import.
This commit is contained in:
		
							
								
								
									
										77
									
								
								OLD/trigger_piwik_archives.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										77
									
								
								OLD/trigger_piwik_archives.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,77 @@ | ||||
| #!/usr/bin/env bash | ||||
|  | ||||
| ## --- | ||||
| ## - !! Notice "" | ||||
| ## - | ||||
| ## - Set a valid shell to th accout, under which apache webserver | ||||
| ## - is running: | ||||
| ## - | ||||
| ## -    usermod -s /bin/sh www-data | ||||
| ## --- | ||||
|  | ||||
| PATH=/usr/local/apache2/bin:/usr/local/php/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||||
|  | ||||
| stats_base_dir="/var/www/stats.warenform.de" | ||||
|  | ||||
| php_bin=/usr/local/php/bin/php | ||||
| http_user=www-data | ||||
|  | ||||
| archive_script="misc/cron/archive.php" | ||||
|  | ||||
| ## -    1.) Create (encrypted) option file: | ||||
| ## -    $ mysql_config_editor set --login-path=piwik_admin --socket=/tmp/mysql.sock --user=piwik_admin --password | ||||
| ## -    $ Password: | ||||
| ## - | ||||
| ## -    2.) Set environment variable mysql_credential_args="--login-path=piwik_admin" | ||||
| ## -    Now, the backup script uses the encrypted option file instead of (unencrypt) password | ||||
| ## -    on command line. | ||||
| #db_host="localhost" | ||||
| #db_user="piwik_admin" | ||||
| #db_passwd="r9ftWbhKcw" | ||||
| mysql_credential_args="--login-path=piwik_admin" | ||||
|  | ||||
| error_log="/tmp/$$.err" | ||||
|  | ||||
| # --------------------------------------------------- # | ||||
| # ------------------- Funktionen -------------------- # | ||||
| # | ||||
| error(){ | ||||
|    echo | ||||
|    echo "----" | ||||
|    echo "$1" | ||||
|    echo | ||||
|    echo "$2" | ||||
|    echo | ||||
| } | ||||
| # | ||||
| # ------------------ Ende Funktionen ---------------- # | ||||
| # --------------------------------------------------- # | ||||
|  | ||||
| cd /tmp | ||||
|  | ||||
| databases=`mysql $mysql_credential_args -N -s -e "show databases" | grep piwik_` | ||||
|  | ||||
| for db_name in $databases ; do | ||||
|  | ||||
|    if [ -f "$stats_base_dir/$db_name/console" ];then | ||||
|  | ||||
|       ## - Alt - nicht mehr empfohlen | ||||
|       #su www-data -c "$php_bin $stats_base_dir/$db_name/$archive_script --url=http://stats.warenform.de/$db_name/" > /dev/null 2> $error_log | ||||
|  | ||||
|       ## - Neu | ||||
|       su $http_user -c "$php_bin $stats_base_dir/$db_name/console core:archive --url=https://stats.warenform.de/$db_name/" > /dev/null 2> $error_log | ||||
|       #su $http_user -c "$php_bin $stats_base_dir/$db_name/console core:archive --url=https://stats.warenform.de/$db_name/" | ||||
|       if [ -f $error_log ]; then | ||||
|          _err=`cat $error_log` | ||||
|          [ -n "$_err" ] && error "Error while executing archive script for database \"$db_name\"" "$_err" | ||||
|          [ -n "$_err" ] && continue | ||||
|       fi | ||||
|    else | ||||
|       error "Error: archive script for database \"$db_name\" not found" "$stats_base_dir/$db_name/console" | ||||
|       continue | ||||
|    fi | ||||
|  | ||||
| done | ||||
|  | ||||
| rm -f $error_log | ||||
| exit 0 | ||||
		Reference in New Issue
	
	Block a user