sourcelab-admin¶
sourcelab-admin is the command line tool for administering a SourceLab instance. It works directly on the instance's database and repositories, so run it on the server, as a user with access to them.
Each command is a noun, what it acts on, then a verb: sourcelab-admin user create, sourcelab-admin group list. Without a noun, or with --help, it lists the nouns; with a noun alone, its verbs; with both and --help, the command's arguments and options.
| Option | Effect |
|---|---|
-c CONFIG, --config CONFIG |
The configuration file to use |
--debug |
Log SourceLab's debug messages, and print the traceback of an error |
--version |
Print SourceLab's version |
The commands follow the same rules:
- The positional arguments name what the command acts on: a user, a project, a branch. Everything else is an option.
- A project is named as in its URL:
nameornamespace/name, andfork/user/nameorfork/user/namespace/namefor a user's fork. --by USERnames the admin acting, where the forge records who did it.--yesanswers yes to the confirmation that a command asks, for scripts.- Dates are written
YYYY-MM-DD.
The command exits with 0 when it succeeds, 3 when it refuses (an unknown user, a bad date), 2 on an error or a mistyped command line, and 130 when interrupted (Ctrl-C). Errors go to the standard error. A command name of Pagure's, such as create-user, fails with the name it has now.
Users¶
| Command | Effect |
|---|---|
user create USER EMAIL [--fullname NAME] [--generate-password] [--yes] |
Create a user, or add an email to an existing one, and change their full name if --fullname is given. Without --generate-password, a new user has no password, and sets one through "Forgot your password?"; with it, an existing user's password is reset, after a confirmation |
user generate-password USER |
Give a user a random password, printed once, and end their login sessions |
user set-password USER [--stdin] |
Set a user's password, asked twice, or read from the first line of the standard input with --stdin, and end their login sessions. Never on the command line, where ps and the shell's history would keep it |
user list [--blocked] |
List the users, or only those blocked, with the date they are blocked until |
user block USER --until DATE [--yes] |
Block a user from any interaction with this instance until a date |
user unblock USER |
Let a blocked user in again |
user purge-spam USER --by ADMIN [--yes] |
Delete a spammer's projects and issues and block them, then list what else they did, which is left to remove by hand |
ssh-key add USER FILE |
Add SSH keys to a user, from a file with one public key per line (- for the standard input). The keys the user already has are skipped, and either every key is added or none |
Setting a password also verifies the user's email, as a password reset does.
Groups¶
| Command | Effect |
|---|---|
group create NAME --creator USER --display NAME [--description TEXT] [--yes] |
Create a group, with its creator as its first member. --yes goes on when group management is turned off |
group list |
List the groups |
Projects¶
| Command | Effect |
|---|---|
project delete PROJECT --by ADMIN [--yes] |
Delete a project |
project fix-hooks |
Set up the git hooks of every project again |
project reset-hook-tokens [--yes] |
Give every project a new hook token, which breaks their webhooks. Only for a security issue |
branch create PROJECT BRANCH --from REF --by ADMIN |
Create a branch, from a branch or a commit |
branch set-default PROJECT BRANCH |
Make a branch the project's default |
watch show PROJECT USER |
Show what a user watches on a project |
watch update PROJECT USER --level LEVEL |
Change what a user watches on a project: default (back to the default), none, issues (issues and pull requests), commits or all |
API tokens¶
| Command | Effect |
|---|---|
token list [--user USER] [--active] [--expired] [--all] |
List the admin API tokens, or all of them with --all |
token show [--stdin] |
Show a token: its owner, its expiration and its ACLs |
token create USER --expires DATE --acl ACL [--acl ACL...] [--yes] |
Create an admin token, and print it. Its ACLs are among ADMIN_API_ACLS: without --acl, the command lists them |
token update --expires DATE [--stdin] [--all] [--yes] |
Change when a token expires, to a date in the future |
token expire [--stdin] [--all] [--yes] |
Expire a token now |
acl sync |
Add the ACLs of the configuration's ACLS to the database. None is removed |
show, update and expire ask for the token, or read it from the first line of the standard input with --stdin: never on the command line, where ps and the shell's history would keep it. --all acts on any token, not only those with admin ACLs.
Plugins¶
The forge's plugins add their own nouns. The builds add:
| Command | Effect |
|---|---|
build-secret add USER --name NAME --ssh-key FILE [--uuid UUID] [--database URL] [--yes] |
Give a user an SSH key secret for their builds, under the key in BUILDS_SECRET_KEY. --yes replaces the user's secret with that UUID, which is refused otherwise. See Installing the builds |