From f5c3a9f54b702920aaac13062a280601ab24a80d Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Fri, 11 Jul 2014 15:13:33 +0530 Subject: [PATCH] ee secure command to change HTTP AUTH & EasyEngine admin port 22222 --- bin/easyengine | 8 ++++++++ bin/update | 4 ---- config/easyengine/ee.conf | 4 ---- .../secure/ee_mod_secure_auth.sh} | 8 ++++---- src/modules/secure/ee_mod_secure_port.sh | 14 ++++++++++++++ 5 files changed, 26 insertions(+), 12 deletions(-) rename src/{lib/ee_lib_http_auth.sh => modules/secure/ee_mod_secure_auth.sh} (75%) create mode 100644 src/modules/secure/ee_mod_secure_port.sh diff --git a/bin/easyengine b/bin/easyengine index c6134335..4f290d3e 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -566,6 +566,14 @@ elif [ "$EE_FIRST" = "debug" ]; then ee_lib_echo_info "tail -f $EE_DEBUG_MSG" fi fi + +elif [ "$EE_FIRST" = "secure" ]; then + if [ "$EE_SECOND" = "--auth" ]; then + ee_mod_secure_auth + elif [ "$EE_SECOND" = "--port" ]; then + ee_mod_secure_port + fi + elif [ "$EE_FIRST" = "update" ]; then ee_lib_echo "Please set/use following alias to update EasyEngine (ee)" echo "alias eeupdate=\"wget -qO /tmp/eeupdate https://raw.githubusercontent.com/rtCamp/easyengine/refactor/bin/update && sudo bash /tmp/eeupdate\"" diff --git a/bin/update b/bin/update index f811ed14..56632023 100644 --- a/bin/update +++ b/bin/update @@ -163,8 +163,6 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then # Get old value from ee.bak file ee_stack_ip=$(grep ip_address /etc/easyengine/ee.bak | cut -d'=' -f2) - ee_auth_user=$(grep htpasswduser /etc/easyengine/ee.bak | cut -d'=' -f2) - ee_auth_pass=$(grep htpasswdpass /etc/easyengine/ee.bak | cut -d'=' -f2) ee_mysql_host=$(grep mysqlhost /etc/easyengine/ee.bak | cut -d'=' -f2) ee_wp_user=$(grep wpadminuser /etc/easyengine/ee.bak | cut -d'=' -f2) ee_wp_pass=$(grep wpadminpass /etc/easyengine/ee.bak | cut -d'=' -f2) @@ -181,8 +179,6 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then # Update value in ee.conf file $EE_CONFIG_SET stack.ip-address "$(echo -n $ee_stack_ip)" && \ - $EE_CONFIG_SET auth.user "$(echo -n $ee_auth_user)" && \ - $EE_CONFIG_SET auth.password "$(echo -n $ee_auth_pass)" && \ $EE_CONFIG_SET mysql.host "$(echo -n $ee_mysql_host)" && \ $EE_CONFIG_SET wordpress.user "$(echo -n $ee_wp_user)" && \ $EE_CONFIG_SET wordpress.password "$(echo -n $ee_wp_pass)" && \ diff --git a/config/easyengine/ee.conf b/config/easyengine/ee.conf index 7795272a..4b6e9204 100644 --- a/config/easyengine/ee.conf +++ b/config/easyengine/ee.conf @@ -5,10 +5,6 @@ gpg-key-fix = false ip-address = -[auth] - user = easyengine - password = easyengine - [mysql] host = localhost db-name = false diff --git a/src/lib/ee_lib_http_auth.sh b/src/modules/secure/ee_mod_secure_auth.sh similarity index 75% rename from src/lib/ee_lib_http_auth.sh rename to src/modules/secure/ee_mod_secure_auth.sh index fc0cdfe0..28a04b59 100644 --- a/src/lib/ee_lib_http_auth.sh +++ b/src/modules/secure/ee_mod_secure_auth.sh @@ -1,6 +1,6 @@ # Setup HTTP authentication -function ee_lib_http_auth() +function ee_mod_secure_auth() { local ee_http_auth_user ee_http_auth_pass @@ -17,9 +17,9 @@ function ee_lib_http_auth() fi # Add HTTP authentication details - $EE_CONFIG_SET auth.user $ee_http_auth_user - $EE_CONFIG_SET auth.password $ee_http_auth_pass + ee_lib_echo "HTTP authentication username: $ee_http_auth_user" &>> $EE_COMMAND_LOG + ee_lib_echo "HTTP authentication password: $ee_http_auth_pass" &>> $EE_COMMAND_LOG # Generate htpasswd-ee file printf "$ee_http_auth_user:$(openssl passwd -crypt $ee_http_auth_pass 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null -} \ No newline at end of file +} diff --git a/src/modules/secure/ee_mod_secure_port.sh b/src/modules/secure/ee_mod_secure_port.sh new file mode 100644 index 00000000..c9cb7a5a --- /dev/null +++ b/src/modules/secure/ee_mod_secure_port.sh @@ -0,0 +1,14 @@ +# Setup EasyEngine admin port + +function ee_mod_secure_port() +{ + read -p "EasyEngine admin port [22222]: " ee_port + + # If enter is pressed, set 22222 + if [[ $ee_port = "" ]]; then + ee_port=22222 + fi + + sed -i "s/listen 22222/listen $ee_port" /etc/nginx/sites-available/22222 \ + || ee_lib_error "Unable to change EasyEngine admin port, exit status = " $? +}