set timezone

Now we can set timezone for Ubuntu and PHP.
This commit is contained in:
Cristhian Martínez Ochoa 2018-06-23 18:31:24 -06:00
parent 5348de5b95
commit 7f0acd43ca
2 changed files with 32 additions and 2 deletions

View file

@ -14,6 +14,22 @@ app_purge() {
}
set_timezone() {
if [[ -n $(conf_read timezone) ]] && grep -Fxq $(conf_read timezone) /opt/webinoly/lib/timezone.dat; then
[[ $1 == "os" || $1 == "all" ]] && sudo timedatectl set-timezone $(conf_read timezone)
# It's not compatible with multi-php feature.
if [[ ($1 == "php" || $1 == "all") && $(conf_read php) == "true" ]]; then
sudo sed -i "/date.timezone =/c\date.timezone = $(conf_read timezone)" /etc/php/$(conf_read php-ver)/fpm/php.ini
sudo service php*-fpm reload
fi
echo "${gre}Timezone: $(conf_read timezone) ${end}"
else
conf_delete timezone
echo "${red}Timezone not found or not valid!${end}"
fi
}
linux_optim() {
api-events_update in4
if [[ $(conf_read linux-optim) == "true" ]]; then
@ -78,6 +94,7 @@ net.ipv4.tcp_max_syn_backlog = 3240000
sudo sed -i "/End of file/i \# WebinolyEnd" /etc/security/limits.conf
swap_create
set_timezone os
sudo sysctl -p
sudo systemctl daemon-reload
@ -289,7 +306,7 @@ php_optim() {
sudo sed -i "/post_max_size =/c\post_max_size = ${maxuploads}M" /etc/php/$ver/fpm/php.ini
sudo sed -i '/max_file_uploads =/c\max_file_uploads = 20' /etc/php/$ver/fpm/php.ini
sudo sed -i '/session.cookie_httponly =/c\session.cookie_httponly = 1' /etc/php/$ver/fpm/php.ini
sudo sed -i '/date.timezone =/c\date.timezone = America/Mexico_City' /etc/php/$ver/fpm/php.ini
set_timezone php
sudo mkdir -p /var/log/php/$ver
sudo touch /var/log/php/$ver/fpm.log

View file

@ -8,7 +8,7 @@ opt="$1"
source /opt/webinoly/lib/webin
# Extract value if exist
if [[ $opt == "-tools-port="* || $opt == "-config-cache="* || $opt == "-clear-cache="* || $opt == "-server-update="* || $opt == "-server-reset="* ]]; then
if [[ $opt == "-tools-port="* || $opt == "-config-cache="* || $opt == "-clear-cache="* || $opt == "-server-update="* || $opt == "-server-reset="* || $opt == "-timezone="* ]]; then
value=$(echo "${opt}" | cut -d'=' -f 2 -s)
opt=$(echo "${opt}" | cut -d'=' -f 1 -s)
fi
@ -330,6 +330,19 @@ elif [[ $opt == "-clear-cache" ]]; then
fi
elif [[ $opt == "-timezone" ]]; then
if [[ -z $value ]]; then
echo "${gre}"
echo "Please, enter a valid Timezone for Ubuntu and PHP."
echo "http://php.net/manual/en/timezones.php"
echo ""
read -p "${blu} Timezone: ${end}" value
echo ""
fi
conf_write timezone $value
set_timezone all
else
echo "${red}Please enter a valid option!${end}"
fi