Skip to content
Snippets Groups Projects
Commit 2721c1ee authored by Bob Mottram's avatar Bob Mottram
Browse files

Handling users

parent 8106710a
No related branches found
No related tags found
No related merge requests found
...@@ -67,6 +67,10 @@ function logging_off_etesync { ...@@ -67,6 +67,10 @@ function logging_off_etesync {
function remove_user_etesync { function remove_user_etesync {
remove_username="$1" remove_username="$1"
cd "/etc/etesync" || exit 72452422
echo "from django.contrib.auth.models import User; u = User.objects.get(username='$remove_username'); u.delete();" | python3 manage.py shell
"${PROJECT_NAME}-pass" -u "$remove_username" --rmapp etesync "${PROJECT_NAME}-pass" -u "$remove_username" --rmapp etesync
} }
...@@ -74,6 +78,10 @@ function add_user_etesync { ...@@ -74,6 +78,10 @@ function add_user_etesync {
new_username="$1" new_username="$1"
new_user_password="$2" new_user_password="$2"
cd "/etc/etesync" || exit 53573582
echo "from django.contrib.auth.models import User; u = User.objects.create_user('$new_username', '${new_username}@$(hostname)', '$new_user_password'); u.save();" | python3 manage.py shell
"${PROJECT_NAME}-pass" -u "$new_username" -a etesync -p "$new_user_password" "${PROJECT_NAME}-pass" -u "$new_username" -a etesync -p "$new_user_password"
echo '0' echo '0'
} }
...@@ -97,7 +105,8 @@ function change_password_etesync { ...@@ -97,7 +105,8 @@ function change_password_etesync {
new_user_password="$2" new_user_password="$2"
cd "/etc/etesync" || exit 3463754637 cd "/etc/etesync" || exit 3463754637
echo -e "${new_user_password}\\n${new_user_password}\\n" | /usr/bin/python3 /etc/etesync/manage.py changepassword "$curr_username"
echo "from django.contrib.auth.models import User; u = User.objects.get(username='$curr_username'); u.set_password('$new_user_password'); u.save();" | python3 manage.py shell
"${PROJECT_NAME}-pass" -u "$curr_username" -a etesync -p "$new_user_password" "${PROJECT_NAME}-pass" -u "$curr_username" -a etesync -p "$new_user_password"
} }
...@@ -142,6 +151,7 @@ function upgrade_etesync { ...@@ -142,6 +151,7 @@ function upgrade_etesync {
set_repo_commit "/etc/etesync" "etesync commit" "$ETESYNC_COMMIT" "$ETESYNC_REPO" set_repo_commit "/etc/etesync" "etesync commit" "$ETESYNC_COMMIT" "$ETESYNC_REPO"
cd /etc/etesync || exit 368252 cd /etc/etesync || exit 368252
pip3 install -U -r requirements.txt pip3 install -U -r requirements.txt
python3 manage.py migrate
chown -R etesync:etesync "/etc/etesync" chown -R etesync:etesync "/etc/etesync"
systemctl restart etesync systemctl restart etesync
} }
...@@ -307,6 +317,7 @@ function install_etesync { ...@@ -307,6 +317,7 @@ function install_etesync {
sed -i "s|ALLOWED_HOSTS =.*|ALLOWED_HOSTS = [ '${ETESYNC_DOMAIN_NAME}', '${ETESYNC_ONION_HOSTNAME}' ]|g" /etc/etesync/etesync_server/settings.py sed -i "s|ALLOWED_HOSTS =.*|ALLOWED_HOSTS = [ '${ETESYNC_DOMAIN_NAME}', '${ETESYNC_ONION_HOSTNAME}' ]|g" /etc/etesync/etesync_server/settings.py
pip3 install -r requirements.txt pip3 install -r requirements.txt
python3 manage.py migrate
etesync_nginx_site=/etc/nginx/sites-available/$ETESYNC_DOMAIN_NAME etesync_nginx_site=/etc/nginx/sites-available/$ETESYNC_DOMAIN_NAME
if [[ "$ONION_ONLY" == "no" ]]; then if [[ "$ONION_ONLY" == "no" ]]; then
...@@ -394,7 +405,8 @@ function install_etesync { ...@@ -394,7 +405,8 @@ function install_etesync {
pip3 install psycopg2-binary pip3 install psycopg2-binary
cd "/etc/etesync" || exit 3463754637 cd "/etc/etesync" || exit 3463754637
echo -e "$ETESYNC_ADMIN_PASSWORD\\n$ETESYNC_ADMIN_PASSWORD\\n" | /usr/bin/python3 /etc/etesync/manage.py createsuperuser --username "$MY_USERNAME" --email "$MY_EMAIL_ADDRESS"
echo "from django.contrib.auth.models import User; User.objects.create_superuser('$MY_USERNAME', '$MY_EMAIL_ADDRESS', '$ETESYNC_ADMIN_PASSWORD')" | python3 manage.py shell
"${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a etesync -p "$ETESYNC_ADMIN_PASSWORD" "${PROJECT_NAME}-pass" -u "$MY_USERNAME" -a etesync -p "$ETESYNC_ADMIN_PASSWORD"
set_completion_param "etesync domain" "$ETESYNC_DOMAIN_NAME" set_completion_param "etesync domain" "$ETESYNC_DOMAIN_NAME"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment