diff --git a/.mod_php_install.sh.swp b/.mod_php_install.sh.swp new file mode 100644 index 0000000..9de26b0 Binary files /dev/null and b/.mod_php_install.sh.swp differ diff --git a/mod_php_install.sh b/mod_php_install.sh index 7b211fd..90be44a 100755 --- a/mod_php_install.sh +++ b/mod_php_install.sh @@ -80,6 +80,10 @@ echo_skipped() { echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]" } +is_int() { + return $(test "$@" -eq "$@" > /dev/null 2>&1); +} + detect_os_1 () { if $(which lsb_release > /dev/null 2>&1) ; then @@ -494,11 +498,28 @@ if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then fi MEMORY_LIMIT="" -echononl "memory_limit in Megabyte !! Append \"M\"? [$_MEMORY_LIMIT] " -read MEMORY_LIMIT -if [ "X$MEMORY_LIMIT" = "X" ]; then - MEMORY_LIMIT=$_MEMORY_LIMIT -fi +while [[ "X$MEMORY_LIMIT" = "X" ]]; do + echononl "memory_limit - Append unit \"K\", \"M\" or \"G\" [$_MEMORY_LIMIT] " + read MEMORY_LIMIT + if [ "X$MEMORY_LIMIT" = "X" ]; then + MEMORY_LIMIT=$_MEMORY_LIMIT + fi + if is_int $MEMORY_LIMIT ; then + MEMORY_LIMIT="${MEMORY_LIMIT}M" + warn "No unit is given. \"M\" was appended: memory_limit: $MEMORY_LIMIT" + continue + fi + _unit="${MEMORY_LIMIT: -1}" + if [[ "$_unit" != "K" ]] && [[ "$_unit" != "M" ]] && [[ "$_unit" != "G" ]]; then + warn "Wrong unit was given for memory_limit. Reenter again" + MEMORY_LIMIT="" + continue + fi + if ! is_int ${MEMORY_LIMIT::-1} ; then + warn "Wrong value for memory_limit. was given. Reenter again" + MEMORY_LIMIT="" + fi +done ## - php.ini: max_execution_time if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then @@ -509,11 +530,17 @@ if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then fi MAX_EXECUTION_TIME="" -echononl "max_execution_time (in Seconds) !! insert ONLY the number? [$_MAX_EXECUTION_TIME] " -read MAX_EXECUTION_TIME -if [ "X$MAX_EXECUTION_TIME" = "X" ]; then - MAX_EXECUTION_TIME=$_MAX_EXECUTION_TIME -fi +while [[ "X$MAX_EXECUTION_TIME" = "X" ]]; do + echononl "max_execution_time (in Seconds) !! insert ONLY the number? [$_MAX_EXECUTION_TIME] " + read MAX_EXECUTION_TIME + if [ "X$MAX_EXECUTION_TIME" = "X" ]; then + MAX_EXECUTION_TIME=$_MAX_EXECUTION_TIME + fi + if ! is_int ${MAX_EXECUTION_TIME} ; then + warn "Wrong value for max_execution_time was given. Reenter again" + MAX_EXECUTION_TIME="" + fi +done ## - php.ini: upload_max_filesize if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then @@ -532,11 +559,17 @@ if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then fi MAX_INPUT_TIME="" -echononl "max_input_time (in Seconds) !! insert ONLY the number? [$_MAX_INPUT_TIME] " -read MAX_INPUT_TIME -if [ "X$MAX_INPUT_TIME" = "X" ]; then - MAX_INPUT_TIME=$_MAX_INPUT_TIME -fi +while [[ "X$MAX_INPUT_TIME" = "X" ]]; do + echononl "max_input_time (in Seconds) !! insert ONLY the number? [$_MAX_INPUT_TIME] " + read MAX_INPUT_TIME + if [ "X$MAX_INPUT_TIME" = "X" ]; then + MAX_INPUT_TIME=$_MAX_INPUT_TIME + fi + if ! is_int ${MAX_INPUT_TIME} ; then + warn "Wrong value for max_input_time was given. Reenter again" + MAX_INPUT_TIME="" + fi +done ## - php.ini: upload_max_filesize if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then @@ -547,11 +580,28 @@ if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then fi UPLOAD_MAX_FILESIZE="" -echononl "upload_max_filesize in Megabyte !! Append \"M\"? [$_UPLOAD_MAX_FILESIZE] " -read UPLOAD_MAX_FILESIZE -if [ "X$UPLOAD_MAX_FILESIZE" = "X" ]; then - UPLOAD_MAX_FILESIZE=$_UPLOAD_MAX_FILESIZE -fi +while [[ "X$UPLOAD_MAX_FILESIZE" = "X" ]]; do + echononl "upload_max_filesize - Append unit \"K\", \"M\" or \"G\" [$_UPLOAD_MAX_FILESIZE] " + read UPLOAD_MAX_FILESIZE + if [ "X$UPLOAD_MAX_FILESIZE" = "X" ]; then + UPLOAD_MAX_FILESIZE=$_UPLOAD_MAX_FILESIZE + fi + if is_int $UPLOAD_MAX_FILESIZE ; then + UPLOAD_MAX_FILESIZE="${UPLOAD_MAX_FILESIZE}M" + warn "No unit is given. \"M\" was appended: upload_max_filesize: $UPLOAD_MAX_FILESIZE" + continue + fi + _unit="${UPLOAD_MAX_FILESIZE: -1}" + if [[ "$_unit" != "K" ]] && [[ "$_unit" != "M" ]] && [[ "$_unit" != "G" ]]; then + warn "Wrong unit was given for upload_max_filesize Reenter again" + UPLOAD_MAX_FILESIZE="" + continue + fi + if ! is_int ${UPLOAD_MAX_FILESIZE::-1} ; then + warn "Wrong value for upload_max_filesize was given. Reenter again" + UPLOAD_MAX_FILESIZE="" + fi +done ## - php.ini: post_max_size if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then @@ -562,11 +612,28 @@ if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then fi POST_MAX_SIZE="" -echononl "post_max_size in Megabyte !! Append \"M\"? [$_POST_MAX_SIZE] " -read POST_MAX_SIZE -if [ "X$POST_MAX_SIZE" = "X" ]; then - POST_MAX_SIZE=$_POST_MAX_SIZE -fi +while [[ "X$POST_MAX_SIZE" = "X" ]]; do + echononl "post_max_size - Append unit \"K\", \"M\" or \"G\" [$_POST_MAX_SIZE] " + read POST_MAX_SIZE + if [ "X$POST_MAX_SIZE" = "X" ]; then + POST_MAX_SIZE=$_POST_MAX_SIZE + fi + if is_int $POST_MAX_SIZE ; then + POST_MAX_SIZE="${POST_MAX_SIZE}M" + warn "No unit was given. So I apaended \"M\": post_max_size: $POST_MAX_SIZE" + continue + fi + _unit="${POST_MAX_SIZE: -1}" + if [[ "$_unit" != "K" ]] && [[ "$_unit" != "M" ]] && [[ "$_unit" != "G" ]]; then + warn "Wrong unit was given for post_max_size. Reenter again" + POST_MAX_SIZE="" + continue + fi + if ! is_int ${POST_MAX_SIZE::-1} ; then + warn "Wrong value for post_max_size was given. Reenter again" + POST_MAX_SIZE="" + fi +done echo ""