Skip to content
This repository was archived by the owner on Feb 27, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions charms/trusty/clearwater-homestead/actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
create-update-user:
description: Create a user, or update a user if they already exist.
params:
number:
description: The number to provision
type: string
password:
description: The number's password
type: string
required: [number, password]
additionalProperties: false
delete-user:
description: Delete a user. If the user does not exist, this is still considered success.
params:
number:
description: The number to provision
type: string
required: [number]
additionalProperties: false
18 changes: 18 additions & 0 deletions charms/trusty/clearwater-homestead/actions/create-update-user
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -ex

# Get the configuration and action parameters.
home_domain=$(config-get zone)
number=$(action-get number)
password=$(action-get password)


# If the user doesn't exist, try to create them. Otherwise, try to update them.
if ! sudo -S /usr/share/clearwater/bin/display_user $number $home_domain ;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why sudo -S (specifically the -S)? We're not providing a username or password here. Surely if the current user is not already authenticated, there's no way we can succeed?

then
echo "Subscriber doesn't exist - creating"
sudo -S /usr/share/clearwater/bin/create_user $number $home_domain $password

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Minor) indentation.

else
echo "Subscriber exists - updating"
sudo -S /usr/share/clearwater/bin/update_user $number $home_domain --password $password
fi
9 changes: 9 additions & 0 deletions charms/trusty/clearwater-homestead/actions/delete-user
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

# Get the configuration and action parameters.
home_domain=$(config-get zone)
number=$(action-get number)

# Delete the user.
sudo -S /usr/share/clearwater/bin/delete_user -y $number $home_domain