mirror of
https://github.com/ovh/the-bastion.git
synced 2024-11-10 17:26:51 +08:00
fix: setup-first-admin-account.sh: support to add several admins
Fixes #202
This commit is contained in:
parent
c61a3eaae9
commit
8d2aaf8d8f
1 changed files with 13 additions and 1 deletions
|
@ -22,4 +22,16 @@ fi
|
|||
|
||||
add_user_to_group_compat "$1" "osh-admin"
|
||||
|
||||
sed_compat 's/^"adminAccounts": \[\]/"adminAccounts": ["'"$1"'"]/' "$BASTION_ETC_DIR/bastion.conf"
|
||||
configline=$(BASEDIR="$basedir" ACCOUNT="$1" perl -e '
|
||||
use lib $ENV{BASEDIR}."/lib/perl";
|
||||
use JSON;
|
||||
use OVH::Bastion;
|
||||
my $C = OVH::Bastion::load_configuration();
|
||||
if (!$C->value || ref $C->value->{adminAccounts} ne "ARRAY") { die "Could not add $ENV{ACCOUNT} in \"adminAccounts\" of bastion.conf, please do it manually!"; }
|
||||
push @{ $C->value->{adminAccounts} }, $ENV{ACCOUNT};
|
||||
print encode_json($C->value->{adminAccounts});
|
||||
')
|
||||
|
||||
if [ -n "$configline" ]; then
|
||||
sed_compat 's/^"adminAccounts": .*/"adminAccounts": '"$configline"',/' "$BASTION_ETC_DIR/bastion.conf"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue