Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
Signed-off-by: Teddysun <i@teddysun.com>
  • Loading branch information
teddysun committed Apr 11, 2019
1 parent a4348af commit 05cd99d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 34 deletions.
59 changes: 30 additions & 29 deletions lamp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ Options:
--db_data_path [location] Database Data Location. for example: /data/db
--db_root_pwd [password] Database root password. for example: lamp.sh
--php_option [1-6] PHP version
--php_extensions [ext name] PHP extensions: ioncube, xcache, imagick,
--php_extensions [ext name] PHP extensions:
ioncube, xcache, imagick,
gmagick, memcached, redis,
mongodb, libsodium, swoole,
yaf, xdebug
Expand Down Expand Up @@ -106,11 +107,11 @@ process(){
--apache_option)
apache_option=$2
if ! is_digit ${apache_option}; then
echo "Error: apache_option input error. please only input a number."
log "Error" "apache_option input error. please only input a number."
exit 1
fi
[[ "${apache_option}" -lt 1 || "${apache_option}" -gt 2 ]] && { echo "Error: apache_option input error. please only input a number between 1 and 2"; exit 1; }
eval apache=${apache_arr[$apache_option-1]}
[[ "${apache_option}" -lt 1 || "${apache_option}" -gt 2 ]] && { log "Error" "apache_option input error. please only input a number between 1 and 2"; exit 1; }
eval apache=${apache_arr[${apache_option}-1]}
;;
--apache_modules)
apache_modules=$2
Expand All @@ -125,8 +126,8 @@ process(){
echo "Error: php_option input error. please only input a number."
exit 1
fi
[[ "${php_option}" -lt 1 || "${php_option}" -gt 6 ]] && { echo "Error: php_option input error. please only input a number between 1 and 6"; exit 1; }
eval php=${php_arr[$php_option-1]}
[[ "${php_option}" -lt 1 || "${php_option}" -gt 6 ]] && { log "Error" "php_option input error. please only input a number between 1 and 6"; exit 1; }
eval php=${php_arr[${php_option}-1]}
;;
--php_extensions)
php_extensions=$2
Expand All @@ -146,59 +147,59 @@ process(){
--db_option)
db_option=$2
if ! is_digit ${db_option}; then
echo "Error: db_option input error. please only input a number."
log "Error" "db_option input error. please only input a number."
exit 1
fi
[[ "${db_option}" -lt 1 || "${db_option}" -gt 14 ]] && { echo "Error: db_option input error. please only input a number between 1 and 14"; exit 1; }
eval mysql=${mysql_arr[$db_option-1]}
[[ "${db_option}" -lt 1 || "${db_option}" -gt 14 ]] && { log "Error" "db_option input error. please only input a number between 1 and 14"; exit 1; }
eval mysql=${mysql_arr[${db_option}-1]}
if [ "${mysql}" == "${mariadb10_3_filename}" ] && version_lt $(get_libc_version) 2.14; then
echo "Error: db_option input error. ${mariadb10_3_filename} not support your OS, please input a correct number."
log "Error" "db_option input error. ${mariadb10_3_filename} is not be supported in your OS, please input a correct number."
exit 1
fi
if [ "${mysql}" == "${percona8_0_filename}" ] && ! is_64bit; then
echo "Error: db_option input error. ${percona8_0_filename} not support your OS, please input a correct number."
log "Error" "db_option input error. ${percona8_0_filename} is not be supported in your OS, please input a correct number."
exit 1
fi
;;
--db_data_path)
db_data_path=$2
if ! echo ${db_data_path} | grep -q "^/"; then
echo "Error: db_data_path input error. please input a correct location."
log "Error" "db_data_path input error. please input a correct location."
exit 1
fi
;;
--db_root_pwd)
db_root_pwd=$2
if printf '%s' "${db_root_pwd}" | LC_ALL=C grep -q '[^ -~]\+'; then
echo "Error: db_root_pwd input error, must not contain non-ASCII characters."
log "Error" "db_root_pwd input error, must not contain non-ASCII characters."
exit 1
fi
[ -n "$(echo ${db_root_pwd} | grep '[+|&]')" ] && { echo "Error: db_root_pwd input error, must not contain special characters like + and &"; exit 1; }
[ -n "$(echo ${db_root_pwd} | grep '[+|&]')" ] && { log "Error" "db_root_pwd input error, must not contain special characters like + and &"; exit 1; }
if (( ${#db_root_pwd} < 5 )); then
echo "Error: db_root_pwd input error, must more than 5 characters."
log "Error" "db_root_pwd input error, must more than 5 characters."
exit 1
fi
;;
--phpmyadmin_option)
phpmyadmin_option=$2
if ! is_digit ${phpmyadmin_option}; then
echo "Error: phpmyadmin_option input error. please only input a number."
log "Error" "phpmyadmin_option input error. please only input a number."
exit 1
fi
[[ "${phpmyadmin_option}" -lt 1 || "${phpmyadmin_option}" -gt 2 ]] && { echo "Error: phpmyadmin_option input error. please only input a number between 1 and 2"; exit 1; }
eval phpmyadmin=${phpmyadmin_arr[$phpmyadmin_option-1]}
[[ "${phpmyadmin_option}" -lt 1 || "${phpmyadmin_option}" -gt 2 ]] && { log "Error" "phpmyadmin_option input error. please only input a number between 1 and 2"; exit 1; }
eval phpmyadmin=${phpmyadmin_arr[${phpmyadmin_option}-1]}
;;
--kodexplorer_option)
kodexplorer_option=$2
if ! is_digit ${kodexplorer_option}; then
echo "Error: kodexplorer_option input error. please only input a number."
log "Error" "kodexplorer_option input error. please only input a number."
exit 1
fi
[[ "${kodexplorer_option}" -lt 1 || "${kodexplorer_option}" -gt 2 ]] && { echo "Error: kodexplorer_option input error. please only input a number between 1 and 2"; exit 1; }
eval kodexplorer=${kodexplorer_arr[$kodexplorer_option-1]}
[[ "${kodexplorer_option}" -lt 1 || "${kodexplorer_option}" -gt 2 ]] && { log "Error" "kodexplorer_option input error. please only input a number between 1 and 2"; exit 1; }
eval kodexplorer=${kodexplorer_arr[${kodexplorer_option}-1]}
;;
*)
echo "Error: unknown argument: $1" && exit 1
log "Error" "unknown argument: $1" && exit 1
;;
esac
shift 2
Expand All @@ -217,12 +218,12 @@ set_parameters(){
[ -z "${php_modules_install}" ] && php_modules_install="do_not_install"
[ "${php}" == "do_not_install" ] && php_modules_install="do_not_install"
if [ -n "${php_modules_install}" ] && [ "${php}" == "${php5_6_filename}" ]; then
if_in_array "${php_libsodium_filename}" "${php_modules_install}" && { echo "Error: ${php_libsodium_filename} is not support ${php}, please remove php extension: libsodium."; exit 1; }
if_in_array "${swoole_filename}" "${php_modules_install}" && { echo "Error: ${swoole_filename} is not support ${php}, please remove php extension: swoole."; exit 1; }
if_in_array "${yaf_filename}" "${php_modules_install}" && { echo "Error: ${yaf_filename} is not support ${php}, please remove php extension: yaf."; exit 1; }
if_in_array "${php_libsodium_filename}" "${php_modules_install}" && { log "Error" "${php_libsodium_filename} is not support ${php}, please remove php extension: libsodium."; exit 1; }
if_in_array "${swoole_filename}" "${php_modules_install}" && { log "Error" "${swoole_filename} is not support ${php}, please remove php extension: swoole."; exit 1; }
if_in_array "${yaf_filename}" "${php_modules_install}" && { log "Error" "${yaf_filename} is not support ${php}, please remove php extension: yaf."; exit 1; }
fi
if [ -n "${php_modules_install}" ] && [ "${php}" != "${php5_6_filename}" ]; then
if_in_array "${xcache_filename}" "${php_modules_install}" && { echo "Error: ${xcache_filename} is not support ${php}, please remove php extension: xcache."; exit 1; }
if_in_array "${xcache_filename}" "${php_modules_install}" && { log "Error" "${xcache_filename} is not support ${php}, please remove php extension: xcache."; exit 1; }
php_modules_install=(${php_modules_install})
php_modules_install=(${php_modules_install[@]/#${xdebug_filename}/${xdebug_filename2}})
php_modules_install=(${php_modules_install[@]/#${php_redis_filename}/${php_redis_filename2}})
Expand Down Expand Up @@ -262,11 +263,11 @@ lamp_auto(){

main() {
if [ -z "$1" ]; then
pre_setting 2>&1 | tee ${cur_dir}/lamp.log
pre_setting
else
process "$@"
set_parameters
lamp_auto 2>&1 | tee ${cur_dir}/lamp.log
lamp_auto
fi
}

Expand All @@ -280,4 +281,4 @@ load_config
rootness

#Run it
main "$@"
main "$@" 2>&1 | tee ${cur_dir}/lamp.log
10 changes: 5 additions & 5 deletions upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ upgrade_menu(){

while true
do
echo -e "\t\033[32m1\033[0m. Upgrade Apache"
echo -e "\t\033[32m2\033[0m. Upgrade MySQL/MariaDB/Percona"
echo -e "\t\033[32m3\033[0m. Upgrade PHP"
echo -e "\t\033[32m4\033[0m. Upgrade phpMyAdmin"
echo -e "\t\033[32m5\033[0m. Exit"
echo -e "\t\033[1;32m1\033[0m. Upgrade Apache"
echo -e "\t\033[1;32m2\033[0m. Upgrade MySQL/MariaDB/Percona"
echo -e "\t\033[1;32m3\033[0m. Upgrade PHP"
echo -e "\t\033[1;32m4\033[0m. Upgrade phpMyAdmin"
echo -e "\t\033[1;32m5\033[0m. Exit"
echo
read -p "Please input a number: " number
if [[ ! ${number} =~ ^[1-5]$ ]]; then
Expand Down

0 comments on commit 05cd99d

Please sign in to comment.