Bob Mottram 8 anni fa
parent
commit
ef4dd4fa38
1 ha cambiato i file con 9 aggiunte e 6 eliminazioni
  1. 9
    6
      src/freedombone-app-radicale

+ 9
- 6
src/freedombone-app-radicale Vedi File

49
 function remove_user_radicale {
49
 function remove_user_radicale {
50
     remove_username="$1"
50
     remove_username="$1"
51
     if grep "$remove_username:" ${RADICALE_DIRECTORY}/users; then
51
     if grep "$remove_username:" ${RADICALE_DIRECTORY}/users; then
52
-        sed -i "/$remove_username/d" ${RADICALE_DIRECTORY}/users
52
+        sed -i "/$remove_username:/d" ${RADICALE_DIRECTORY}/users
53
         systemctl reload radicale
53
         systemctl reload radicale
54
     fi
54
     fi
55
 }
55
 }
57
 function add_user_radicale {
57
 function add_user_radicale {
58
     new_username="$1"
58
     new_username="$1"
59
     new_user_password="$2"
59
     new_user_password="$2"
60
-    new_user_hash=$(echo -n "$new_user_password" | sha1sum | awk -F ' ' '{print $1}')
61
 
60
 
62
-    if ! grep "$new_username:$new_user_hash" ${RADICALE_DIRECTORY}/users; then
63
-        printf "$new_username:$new_user_hash\n" >> ${RADICALE_DIRECTORY}/users
61
+    if [ ! -f ${RADICALE_DIRECTORY}/users ]; then
62
+        touch ${RADICALE_DIRECTORY}/users
63
+    fi
64
+
65
+    if ! grep "$new_username:" ${RADICALE_DIRECTORY}/users; then
66
+        htpasswd -Bb ${RADICALE_DIRECTORY}/users "$new_username" "$new_user_password"
64
         systemctl reload radicale
67
         systemctl reload radicale
65
     fi
68
     fi
66
     echo '0'
69
     echo '0'
207
     fi
210
     fi
208
     chown -R www-data:www-data /var/log/radicale
211
     chown -R www-data:www-data /var/log/radicale
209
 
212
 
210
-    apt-get -yq install python-radicale uwsgi uwsgi-plugin-python radicale
213
+    apt-get -yq install python-radicale uwsgi uwsgi-plugin-python radicale apache2-utils
211
 
214
 
212
     if [ ! -d ${RADICALE_DIRECTORY} ]; then
215
     if [ ! -d ${RADICALE_DIRECTORY} ]; then
213
         echo $"ERROR: radicale does not appear to have installed"
216
         echo $"ERROR: radicale does not appear to have installed"
226
     echo '[auth]' >  ${RADICALE_DIRECTORY}/config
229
     echo '[auth]' >  ${RADICALE_DIRECTORY}/config
227
     echo 'type = htpasswd' >> ${RADICALE_DIRECTORY}/config
230
     echo 'type = htpasswd' >> ${RADICALE_DIRECTORY}/config
228
     echo "htpasswd_filename = ${RADICALE_DIRECTORY}/users" >> ${RADICALE_DIRECTORY}/config
231
     echo "htpasswd_filename = ${RADICALE_DIRECTORY}/users" >> ${RADICALE_DIRECTORY}/config
229
-    echo 'htpasswd_encryption = sha1' >> ${RADICALE_DIRECTORY}/config
232
+    echo 'htpasswd_encryption = bcrypt' >> ${RADICALE_DIRECTORY}/config
230
     echo '' >> ${RADICALE_DIRECTORY}/config
233
     echo '' >> ${RADICALE_DIRECTORY}/config
231
     echo '[rights]' >> ${RADICALE_DIRECTORY}/config
234
     echo '[rights]' >> ${RADICALE_DIRECTORY}/config
232
     echo 'type = owner_only' >> ${RADICALE_DIRECTORY}/config
235
     echo 'type = owner_only' >> ${RADICALE_DIRECTORY}/config