No easy way to grant ALL players a privilege?

Post Reply
AmyMoriyama
Member
Posts: 107
Joined: Wed Jun 30, 2021 14:53
GitHub: AmyMoriyama

No easy way to grant ALL players a privilege?

by AmyMoriyama » Post

So, when I began my server I missed some privs to be given by default. Logically, you would think you could just do /grant all priv but this doesn't work and it seems the only way is to find the name of every player and grant each one the priv one at a time.

There has to be a better way, right?

User avatar
1faco
Member
Posts: 84
Joined: Tue Sep 08, 2020 20:32
GitHub: minefaco
In-game: faco

Re: No easy way to grant ALL players a privilege?

by 1faco » Post

a ingame solution: you can place a commandblock from mesecons at spawn with a button. so you write "grant @nearest priv". (or something like that).

Mineminer
Member
Posts: 325
Joined: Mon Mar 05, 2018 04:05

Re: No easy way to grant ALL players a privilege?

by Mineminer » Post

1faco wrote:
Tue Jul 27, 2021 15:48
a ingame solution: you can place a commandblock from mesecons at spawn with a button. so you write "grant @nearest priv". (or something like that).
Wire it to a wooden pressure plate near spawn point ensuring the players will presses on it as they passes by. :)

User avatar
Minix
Member
Posts: 144
Joined: Thu Nov 12, 2020 13:51
In-game: Minix

Re: No easy way to grant ALL players a privilege?

by Minix » Post

I made this script for someone else: viewtopic.php?f=10&t=26917

This is an automated bash script for granting all players on the server a specific privilege.

This works on a Linux system and you need to install the sqlite3 package that brings the sqlite3 command line program so I am assuming you know how to use the command line and that you have a Linux system available.

Copy this bash script code into a file and name it as you wish, make sure to make it executable with chmod:

Code: Select all

#! /bin/bash

players=$(expr $(sqlite3 auth.sqlite ".dump auth" | wc -l) - 4)
for id in {1..${players}}
do
	cat sql_cmd | sed "s/id/$id/" | sqlite3 auth.sqlite
	mv auth.sqlite.tmp auth.sqlite
done
Then copy this sqlite script into a file called "sql_cmd", note that you will have to change 'fly' for the privilege you want to grant, this is an example of granting fly:

Code: Select all

INSERT INTO user_privileges VALUES (id, "fly");
.save auth.sqlite.tmp
.quit
Now you have to search your world directory for the file auth.sqlite, that is the database that holds the privilege and authentication data of players.

MAKE SURE TO BACKUP your auth.sqlite file before proceeding. After backing up, copy auth.sqlite and those two scripts into the same directory, get into that directory and run the bash script as "./name-of-your-script"

After running the script you can copy the auth.sqlite file that you just modified to your world directory and start your server.

Maybe there should be a feature similar to globbing on Linux shells for the Minetest command line.

User avatar
Blockhead
Member
Posts: 1602
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: No easy way to grant ALL players a privilege?

by Blockhead » Post

There is a configuration setting to add privileges when new players join:
e.g.
default_privs = shout, fly, creative
Add the privs you want to your minetest.conf.

Minix has already posted the solution for upgrading your existing players.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Linuxdirk
Member
Posts: 3216
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: No easy way to grant ALL players a privilege?

by Linuxdirk » Post

Blockhead wrote:
Fri Jul 30, 2021 02:28
There is a configuration setting to add privileges when new players join:
As far as I remember this is only relevant for players who never were on the server before, like, default_privs are only granted on first join.

User avatar
Blockhead
Member
Posts: 1602
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: No easy way to grant ALL players a privilege?

by Blockhead » Post

Linuxdirk wrote:
Fri Jul 30, 2021 12:46
As far as I remember this is only relevant for players who never were on the server before, like, default_privs are only granted on first join.
Correct. But that is why I added the second paragraph of my post:
Blockhead wrote:
Fri Jul 30, 2021 02:28
Minix has already posted the solution for upgrading your existing players.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

AmyMoriyama
Member
Posts: 107
Joined: Wed Jun 30, 2021 14:53
GitHub: AmyMoriyama

Re: No easy way to grant ALL players a privilege?

by AmyMoriyama » Post

Blockhead wrote:
Fri Jul 30, 2021 02:28
Minix has already posted the solution for upgrading your existing players.
I like bash scripting, but that is not a solution. That solution only works under certain specific circumstances. Any solution should be able to be done on any platform that can host a server.

An idea, the default_privs could be expanded to do a simple check on player join. If player joins and has all the privs in the default_privs line, nothing is done. If any are missing, grant them. This would be an actual solution.

User avatar
Linuxdirk
Member
Posts: 3216
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: No easy way to grant ALL players a privilege?

by Linuxdirk » Post

Or add a mod that gives players the needed privileges when they join.

This would be platform-independent and you don’t need to manually mess with the database.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests