Merge pull request #19229 from danimo/cleanup/runuser
cleanup: use runuser instead of sudo
This commit is contained in:
commit
b9eab9361e
@ -10,13 +10,13 @@ cd "$(dirname "$0")"
|
||||
# Install Postgresql
|
||||
apt update
|
||||
apt install postgresql postgresql-contrib -y
|
||||
sudo -u postgres psql -c "alter user postgres password 'bbb_graphql'"
|
||||
sudo -u postgres psql -c "drop database if exists bbb_graphql with (force)"
|
||||
sudo -u postgres psql -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
|
||||
sudo -u postgres psql -c "alter database bbb_graphql set timezone to 'UTC'"
|
||||
sudo -u postgres psql -U postgres -d bbb_graphql -a -f bbb_schema.sql --set ON_ERROR_STOP=on
|
||||
sudo -u postgres psql -c "drop database if exists hasura_app with (force)"
|
||||
sudo -u postgres psql -c "create database hasura_app"
|
||||
runuser -u postgres -- psql -c "alter user postgres password 'bbb_graphql'"
|
||||
runuser -u postgres -- psql -c "drop database if exists bbb_graphql with (force)"
|
||||
runuser -u postgres -- psql -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
|
||||
runuser -u postgres -- psql -c "alter database bbb_graphql set timezone to 'UTC'"
|
||||
runuser -u postgres -- psql -U postgres -d bbb_graphql -a -f bbb_schema.sql --set ON_ERROR_STOP=on
|
||||
runuser -u postgres -- psql -c "drop database if exists hasura_app with (force)"
|
||||
runuser -u postgres -- psql -c "create database hasura_app"
|
||||
|
||||
echo "Creating frontend in bbb_graphql"
|
||||
DATABASE_FRONTEND_USER="bbb_frontend"
|
||||
|
@ -16,12 +16,12 @@ if [ "$hasura_status" = "active" ]; then
|
||||
fi
|
||||
|
||||
echo "Restarting database bbb_graphql"
|
||||
sudo -u postgres psql -q -c "drop database if exists bbb_graphql with (force)"
|
||||
sudo -u postgres psql -q -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
|
||||
sudo -u postgres psql -q -c "alter database bbb_graphql set timezone to 'UTC'"
|
||||
runuser -u postgres -- psql -q -c "drop database if exists bbb_graphql with (force)"
|
||||
runuser -u postgres -- psql -q -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
|
||||
runuser -u postgres -- psql -q -c "alter database bbb_graphql set timezone to 'UTC'"
|
||||
|
||||
echo "Creating tables in bbb_graphql"
|
||||
sudo -u postgres psql -U postgres -d bbb_graphql -q -f bbb_schema.sql --set ON_ERROR_STOP=on
|
||||
runuser -u postgres -- psql -U postgres -d bbb_graphql -q -f bbb_schema.sql --set ON_ERROR_STOP=on
|
||||
|
||||
echo "Creating frontend in bbb_graphql"
|
||||
DATABASE_FRONTEND_USER="bbb_frontend"
|
||||
|
@ -942,7 +942,7 @@ def BBB_server_standalone(hostname, x=100, y=300):
|
||||
install_options.append('-g')
|
||||
|
||||
install_options_str = ' '.join(install_options)
|
||||
user_data['runcmd'].append(f'sudo -u ubuntu RELEASE="{args.release}" INSTALL_OPTIONS="{install_options_str}" /testserver.sh')
|
||||
user_data['runcmd'].append(f'runuser -u ubuntu RELEASE="{args.release}" INSTALL_OPTIONS="{install_options_str}" /testserver.sh')
|
||||
|
||||
if notification_url:
|
||||
user_data['phone_home'] = {'url': notification_url, 'tries': 1}
|
||||
|
@ -5,19 +5,19 @@ case "$1" in
|
||||
|
||||
fc-cache -f
|
||||
|
||||
sudo -u postgres psql -c "alter user postgres password 'bbb_graphql'"
|
||||
sudo -u postgres psql -c "drop database if exists bbb_graphql with (force)"
|
||||
sudo -u postgres psql -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
|
||||
sudo -u postgres psql -c "alter database bbb_graphql set timezone to 'UTC'"
|
||||
sudo -u postgres psql -U postgres -d bbb_graphql -q -f /usr/share/bbb-graphql-server/bbb_schema.sql --set ON_ERROR_STOP=on
|
||||
runuser -u postgres -- psql -c "alter user postgres password 'bbb_graphql'"
|
||||
runuser -u postgres -- psql -c "drop database if exists bbb_graphql with (force)"
|
||||
runuser -u postgres -- psql -c "create database bbb_graphql WITH TEMPLATE template0 LC_COLLATE 'C.UTF-8'"
|
||||
runuser -u postgres -- psql -c "alter database bbb_graphql set timezone to 'UTC'"
|
||||
runuser -u postgres -- psql -U postgres -d bbb_graphql -q -f /usr/share/bbb-graphql-server/bbb_schema.sql --set ON_ERROR_STOP=on
|
||||
|
||||
DATABASE_NAME="hasura_app"
|
||||
DB_EXISTS=$(sudo -u postgres psql -U postgres -tAc "SELECT 1 FROM pg_database WHERE datname='$DATABASE_NAME'")
|
||||
DB_EXISTS=$(runuser -u postgres -- psql -U postgres -tAc "SELECT 1 FROM pg_database WHERE datname='$DATABASE_NAME'")
|
||||
if [ "$DB_EXISTS" = '1' ]
|
||||
then
|
||||
echo "Database $DATABASE_NAME already exists"
|
||||
else
|
||||
sudo -u postgres psql -c "create database hasura_app"
|
||||
runuser -u postgres -- psql -c "create database hasura_app"
|
||||
echo "Database $DATABASE_NAME created"
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user