Browse Source

Changing the dokuwki password

Bob Mottram 8 years ago
parent
commit
232cb7fbf0
1 changed files with 19 additions and 7 deletions
  1. 19
    7
      src/freedombone-app-dokuwiki

+ 19
- 7
src/freedombone-app-dokuwiki View File

41
 DOKUWIKI_ONION_PORT=8089
41
 DOKUWIKI_ONION_PORT=8089
42
 
42
 
43
 dokuwiki_variables=(ONION_ONLY
43
 dokuwiki_variables=(ONION_ONLY
44
-                MY_USERNAME
45
-                DOKUWIKI_TITLE
46
-                DOKUWIKI_DOMAIN_NAME
47
-                DOKUWIKI_CODE
48
-                DDNS_PROVIDER)
44
+                    MY_USERNAME
45
+                    DOKUWIKI_TITLE
46
+                    DOKUWIKI_DOMAIN_NAME
47
+                    DOKUWIKI_CODE
48
+                    DDNS_PROVIDER)
49
 
49
 
50
 function install_interactive_dokuwiki {
50
 function install_interactive_dokuwiki {
51
     if [[ $ONION_ONLY != "no" ]]; then
51
     if [[ $ONION_ONLY != "no" ]]; then
61
 }
61
 }
62
 
62
 
63
 function change_password_dokuwiki {
63
 function change_password_dokuwiki {
64
-    echo -n ''
65
-    #${PROJECT_NAME}-pass -u $1 -a dokuwiki -p "$2"
64
+    curr_username="$1"
65
+    new_user_password="$2"
66
+
67
+    if grep "$curr_username:" /var/lib/dokuwiki/acl/users.auth.php; then
68
+        HASHED_DOKUWIKI_PASSWORD=$(echo -n "$new_user_password" | md5sum | awk -F ' ' '{print $1}')
69
+        existing_user=$(cat /var/lib/dokuwiki/acl/users.auth.php | grep "$curr_username:" | hean -n 1)
70
+        if [[ "$existing_user" == *":admin,"* ]]; then
71
+            sed -i "s|$curr_username:.*|$curr_username:$HASHED_DOKUWIKI_PASSWORD:$curr_username:$curr_username@$HOSTNAME:admin,user,upload|g" /var/lib/dokuwiki/acl/users.auth.php
72
+        else
73
+            sed -i "s|$curr_username:.*|$curr_username:$HASHED_DOKUWIKI_PASSWORD:$curr_username:$curr_username@$HOSTNAME:user,upload|g" /var/lib/dokuwiki/acl/users.auth.php
74
+        fi
75
+        chmod 640 /var/lib/dokuwiki/acl/users.auth.php
76
+        ${PROJECT_NAME}-pass -u $curr_username -a dokuwiki -p "$new_user_password"
77
+    fi
66
 }
78
 }
67
 
79
 
68
 function reconfigure_dokuwiki {
80
 function reconfigure_dokuwiki {