Pomoc rTorrent - inny czas niz systemoy

Paweł Tołoczko

Enterprise Admin...
Q's Architect
8 Listopad 2013
939
270
113
43
Cork
QNAP
TS-x70
Ethernet
1 GbE
Jak w temacie - rTorrent zyje sobie w innej strefe czasowej niz caly serwer.
upload_2014-10-13_15-59-52.png

Problem zostal juz rozwiazany dzieki pomocy @Silas Mariusz

ponizej instrukcja jak zdiagnozowac problem i go rozwiazac:

1. zalogowac sie przez SSH i sprawdzic date systemowa:
Bash:
date
Mon Oct 13 14:04:07 BST 2014
2. sprawdzenie stref czasowych:
Bash:
getcfg Date date.timezone -f /usr/bin/rtorrent/etc/php5/php.ini
Europe/Sarajevo
Bash:
getcfg System "Time Zone" -f /etc/config/uLinux.conf
3. setup + restart uslugi
Bash:
setcfg Date date.timezone UTC -f /usr/bin/rtorrent/etc/php5/php.ini
Bash:
/usr/bin/rtorrent/etc/init.d/php-fpm restart
init.d/php5-fpm: -WAIT 0
init.d/php5-fpm: Gracefully shutting down done.
init.d/php5-fpm: Starting service done.
4. sprawdzenie czy cos sie zmienilo:
Bash:
getcfg Date date.timezone -f /usr/bin/rtorrent/etc/php5/php.ini
Europe/Sarajevo
Bash:
getcfg System "Time Zone" -f /etc/config/uLinux.conf
5. Nic sie nie zmienilo :p
6. Restart Calego serwera:
upload_2014-10-13_16-7-40.png


Wszystko dziala jak nalezy.
 
A gdzie setcfg zapomniałeś, które Ci napisałem przed restartem usługi?
Bash:
setcfg Date date.timezone UTC -f /usr/bin/rtorrent/etc/php5/php.ini
Pokombinuj z różnymi wartościami, np.: GMT, UTC, Etc/GMT+1, Etc/GMT-1, ...

Dopiero wtedy restartuj php-fpm i odśwież UI.

Reference:
PHP: Lista obsługiwanych stref czasowych - Manual
PHP: Inne - Manual
...
 
Aby przy kolejnym uruchomieniu rtorrenta strefa czasowa nie była ponownie załadowana z ustawień serwer QNAP, otwórz w edytorze loader rtorrenta /etc/init.d/rtorrent.sh np. w vi lub w mcedit:
Bash:
mcedit /etc/init.d/rtorrent.sh

Odszukaj:
Bash:
USER_TIMEZONE=
i dopisz do tej zmiennej właściwą strefe czasową w cudzysłowie, np.:"
Bash:
USER_TIMEZONE="Europe/London"

Następnie wyeliminuj z loadera odczyt strefy czasowej z configu systemowego oraz alternatywną procedurę detekcji strefy czasowej:
Odszukaj sekwencję startową:
Bash:
case "$1" in
	"start")
a w niej kilka linijek niżej:
Bash:
[ -f "/etc/config/uLinux.conf" ] && USER_TIMEZONE=`/sbin/getcfg System "Time Zone" -f /etc/config/uLinux.conf`

if [ -n "$USER_TIMEZONE" ]; then
	detect_time_zone
	if [ -n "$USER_TIMEZONE" ]; then
		_log TZ: $USER_TIMEZONE
		update_php_timezone
	else
		warn "TZ: Timezone could not be detected!"
	fi
fi

Wyremuj stawiając hash na początku:
  1. #[ -f "/etc/config/uLinux.conf" ] && USER_TIMEZONE=`/sbin/getcfg System "Time Zone" -f /etc/config/uLinux.conf`
  2. #detect_time_zone
Efekt końcowy:
Bash:
#[ -f "/etc/config/uLinux.conf" ] && USER_TIMEZONE=`/sbin/getcfg System "Time Zone" -f /etc/config/uLinux.conf`

if [ -n "$USER_TIMEZONE" ]; then
	#detect_time_zone
	if [ -n "$USER_TIMEZONE" ]; then
		_log TZ: $USER_TIMEZONE
		update_php_timezone
	else
		warn "TZ: Timezone could not be detected!"
	fi
fi


Metoda alternatywna
Sposób niesprawdzony, zachowując automatyczną detekcję strefy czasowej!
(U mnie jak zwykle działał, ale w niektórych strefach się gubił...)
W Loaderze nic nie zmieniaj, a więc pozostaw pustą zmienną USER_TIMEZONE= oraz wykonanie procedury detect_time_zone a wyremuj tylko:
#[ -f "/etc/config/uLinux.conf" ] && USER_TIMEZONE=`/sbin/getcfg System "Time Zone" -f /etc/config/uLinux.conf`

FYI: Zostanie wykonana detekcja z plików systemowych:
Bash:
# Find Timezone and update php.ini
# ###########################################################################
is_valid_tz_name() {
	echo "$1" | LC_ALL=C grep -qE '^[A-Z][^/ ]*(/[A-Z][^/ ]*)?$' && return 0
	return 1
}
detect_time_zone() {
	[ -n "$USER_TIMEZONE" ] && return

	local hash=
	local hasher=
	local files=
	#local zoneinfoPath=/usr/share/zoneinfo
	local zoneinfoPath=/etc/zoneinfo
	if [ ! -d "$zoneinfoPath" ]; then
		_warn Zone info not found /usr/share/zoneinfo
		return
	fi
	
	if hasher=md5sum; available $hasher || hasher=sha1sum; available $hasher; then
		[ -x "$hasher" ] && hasher="$hasher"
		_log Hasher: $hasher
		hash=$($hasher /etc/localtime | awk '{print $1}')
		_log /etc/localtime $hash
		files="$(find $zoneinfoPath -type f -print | xargs $hasher | grep -E "^$hash\\>" | awk '{print $2}')"
	else
		return
	fi

	# Detect all possible timezone names
	local timezones=
	for path in $files; do
		local tz="${path#$zoneinfoPath/}"
		while true; do
			is_valid_tz_name "$tz" && break
			local newTz="${tz#*/}"
			[ "$newTz" = "$tz" ] && tz= && break
			tz="$newTz"
		done
		is_valid_tz_name "$tz" && timezones="$timezones $tz"
	done

	# Now find the ones PHP likes...
	local okRegions="(Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)"
	for tz in $timezones; do
		echo "$tz" | grep -qE "^$okRegions/" && USER_TIMEZONE="$tz" && return
	done

	# Return the first one we found
	for tz in $timezones; do
		USER_TIMEZONE="$tz"
		return
	done
}
update_php_timezone() {
	# Replace current TZ in php.ini
	local WWW_PHP_INI="$PROGDIR/etc/php5/php.ini"
	if [ ! -f "$WWW_PHP_INI" ]; then
		_warn File not found $WWW_PHP_INI
		return
	fi

	[ -z "$USER_TIMEZONE" ] && USER_TIMEZONE="UTC"
	#[ -z "$USER_TIMEZONE" ] && return

	# Old
#	local zws="[ 	]*"
#	local newLine="date.timezone = $USER_TIMEZONE"
#	if grep -qE "^${zws}${zws}date\\.timezone[ 	=]" "$WWW_PHP_INI"; then
#		sed_i "s!^${zws}${zws}date\\.timezone[ 	=].*\$!$newLine!" "$WWW_PHP_INI"
#	else
#		cat >> "$WWW_PHP_INI" << EOF
#[Date]
#$newLine
#EOF
#	fi

	# New
	setcfg "Date" "date.timezone" "$USER_TIMEZONE" -f "$WWW_PHP_INI"
}
 
  • Lubię to
Reakcje: kaktus