mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Backup php.ini to $raspap_dir/backups folder.
Ask for before changing php configuration of httpOnly and opcache. Do not change session.use_strict_mode, no extra question. Ask to restore backup of php.ini from $raspap_dir/backups folder in uninstall.sh. Signed-off-by: D9ping <D9ping@users.noreply.github.com>
This commit is contained in:
parent
e428271ef2
commit
03f2620e48
@ -17,6 +17,13 @@ else
|
|||||||
php_package="php5-cgi"
|
php_package="php5-cgi"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
phpcgiconf=""
|
||||||
|
if [ "$php_package" = "php7.0-cgi" ]; then
|
||||||
|
phpcgiconf="/etc/php/7.0/cgi/php.ini"
|
||||||
|
elif [ "$php_package" = "php5-cgi" ]; then
|
||||||
|
phpcgiconf="/etc/php5/cgi/php.ini"
|
||||||
|
fi
|
||||||
|
|
||||||
# Outputs a RaspAP Install log line
|
# Outputs a RaspAP Install log line
|
||||||
function install_log() {
|
function install_log() {
|
||||||
echo -e "\033[1;32mRaspAP Install: $*\033[m"
|
echo -e "\033[1;32mRaspAP Install: $*\033[m"
|
||||||
@ -269,23 +276,28 @@ function patch_system_files() {
|
|||||||
|
|
||||||
# Change configuration of php-cgi.
|
# Change configuration of php-cgi.
|
||||||
function reconfigure_php() {
|
function reconfigure_php() {
|
||||||
install_log "Reconfiguring php"
|
if [ ! -f "$phpcgiconf" ]; then
|
||||||
phpcgiconf=""
|
install_warning "PHP configuration could not be found."
|
||||||
if [ "$php_package" = "php7.0-cgi" ]; then
|
return
|
||||||
phpcgiconf="/etc/php/7.0/cgi/php.ini"
|
|
||||||
elif [ "$php_package" = "php5-cgi" ]; then
|
|
||||||
phpcgiconf="/etc/php/cgi/php.ini"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$phpcgiconf" ]; then
|
# Backup php.ini and create symlink for restoring.
|
||||||
# Backup php configuration.
|
datetimephpconf=$(date +%F-%R)
|
||||||
sudo cp "$phpcgiconf" "$phpcgiconf.`date +%F-%R`"
|
sudo cp "$phpcgiconf" "$raspap_dir/backups/php.ini.$datetimephpconf"
|
||||||
# Turn on the httpOnly flag if off.
|
sudo ln -sf "$raspap_dir/backups/php.ini.$datetimephpconf" "$raspap_dir/backups/php.ini"
|
||||||
|
|
||||||
|
echo -n "Turn on httpOnly flag for session cookies(recommended)? [Y/n]: "
|
||||||
|
read answer
|
||||||
|
if [ "$answer" != 'n' ] && [ "$answer" != 'N' ]; then
|
||||||
|
install_log "Php-cgi enabling session.cookie_httponly."
|
||||||
sudo sed -i -E 's/^session\.cookie_httponly\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/session.cookie_httponly = 1/' "$phpcgiconf"
|
sudo sed -i -E 's/^session\.cookie_httponly\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/session.cookie_httponly = 1/' "$phpcgiconf"
|
||||||
# Don't accept uninitialized session ID's.
|
fi
|
||||||
sudo sed -i -E 's/^session\.use_strict_mode\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/session.use_strict_mode = 1/' "$phpcgiconf"
|
|
||||||
if [ "$php_package" = "php7.0-cgi" ]; then
|
if [ "$php_package" = "php7.0-cgi" ]; then
|
||||||
# Enable PHP Zend Opcache.
|
echo -n "Turn on php opcache? [Y/n]: "
|
||||||
|
read answer
|
||||||
|
if [ "$answer" != 'n' ] && [ "$answer" != 'N' ]; then
|
||||||
|
install_log "Php-cgi enabling opcache.enable."
|
||||||
sudo sed -i -E 's/^;?opcache\.enable\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/opcache.enable = 1/' "$phpcgiconf"
|
sudo sed -i -E 's/^;?opcache\.enable\s*=\s*(0|([O|o]ff)|([F|f]alse)|([N|n]o))\s*$/opcache.enable = 1/' "$phpcgiconf"
|
||||||
# Make sure opcache extension is turned on.
|
# Make sure opcache extension is turned on.
|
||||||
if [ -f "/usr/sbin/phpenmod" ]; then
|
if [ -f "/usr/sbin/phpenmod" ]; then
|
||||||
@ -294,8 +306,6 @@ function reconfigure_php() {
|
|||||||
install_warning "phpenmod not found."
|
install_warning "phpenmod not found."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
install_warning "PHP configuration could not be found."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Apply new php configuration.
|
# Apply new php configuration.
|
||||||
|
@ -4,14 +4,28 @@ raspap_user="www-data"
|
|||||||
version=`sed 's/\..*//' /etc/debian_version`
|
version=`sed 's/\..*//' /etc/debian_version`
|
||||||
|
|
||||||
# Determine version and set default home location for lighttpd
|
# Determine version and set default home location for lighttpd
|
||||||
if [ $version -ge 8 ]; then
|
webroot_dir="/var/www/html"
|
||||||
version_msg="Raspian version 8.0 or later"
|
if [ $version -eq 9 ]; then
|
||||||
webroot_dir="/var/www/html"
|
version_msg="Raspian 9.0 (Stretch)"
|
||||||
else
|
php_package="php7.0-cgi"
|
||||||
version_msg="Raspian version earlier than 8.0"
|
elif [ $version -eq 8 ]; then
|
||||||
|
version_msg="Raspian 8.0 (Jessie)"
|
||||||
webroot_dir="/var/www"
|
webroot_dir="/var/www"
|
||||||
|
php_package="php5-cgi"
|
||||||
|
else
|
||||||
|
version_msg="Raspian earlier than 8.0 (Wheezy)"
|
||||||
|
webroot_dir="/var/www"
|
||||||
|
php_package="php5-cgi"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
phpcgiconf=""
|
||||||
|
if [ "$php_package" = "php7.0-cgi" ]; then
|
||||||
|
phpcgiconf="/etc/php/7.0/cgi/php.ini"
|
||||||
|
elif [ "$php_package" = "php5-cgi" ]; then
|
||||||
|
phpcgiconf="/etc/php5/cgi/php.ini"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Outputs a RaspAP Install log line
|
# Outputs a RaspAP Install log line
|
||||||
function install_log() {
|
function install_log() {
|
||||||
echo -e "\033[1;32mRaspAP Install: $*\033[m"
|
echo -e "\033[1;32mRaspAP Install: $*\033[m"
|
||||||
@ -68,6 +82,13 @@ function check_for_backups() {
|
|||||||
sudo cp "$raspap_dir/backups/dhcpcd.conf" /etc/dhcpcd.conf
|
sudo cp "$raspap_dir/backups/dhcpcd.conf" /etc/dhcpcd.conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if [ -f "$raspap_dir/backups/php.ini" ] && [ -f "$phpcgiconf" ]; then
|
||||||
|
echo -n "Restore the last php.ini file? [y/N]: "
|
||||||
|
read answer
|
||||||
|
if [[ $answer -eq 'y' ]]; then
|
||||||
|
sudo cp "$raspap_dir/backups/php.ini" "$phpcgiconf"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
if [ -f "$raspap_dir/backups/rc.local" ]; then
|
if [ -f "$raspap_dir/backups/rc.local" ]; then
|
||||||
echo -n "Restore the last rc.local file? [y/N]: "
|
echo -n "Restore the last rc.local file? [y/N]: "
|
||||||
read answer
|
read answer
|
||||||
@ -75,7 +96,7 @@ function check_for_backups() {
|
|||||||
sudo cp "$raspap_dir/backups/rc.local" /etc/rc.local
|
sudo cp "$raspap_dir/backups/rc.local" /etc/rc.local
|
||||||
else
|
else
|
||||||
echo -n "Remove RaspAP Lines from /etc/rc.local? [Y/n]: "
|
echo -n "Remove RaspAP Lines from /etc/rc.local? [Y/n]: "
|
||||||
if $answer -ne 'n' ]]; then
|
if [[ $answer -ne 'n' ]]; then
|
||||||
sed -i '/#RASPAP/d' /etc/rc.local
|
sed -i '/#RASPAP/d' /etc/rc.local
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user