Database configuration and maintenance

Initialization

Initializing database with oepkgs_djtools

oepkgs_djtools is in tools directory, usage is below:


[euler_blade@samantha oepkgs_packages_configs]$ tools/oepkgs_djtools initdb -d <oepkgs_database_file_path>

Sub command is initdb

  • –database/-d: database file storage path

Steps:

  1. Create an empty database file, Just return an error on file already existing

  2. Create empty tables in system to database, using below SQL commands

[oepkger@oepkgs-koji-hub ~]$ sqlite3 /mnt/storage/repodb/oepkgs.db
SQLite version 3.33.0 2020-08-14 13:23:32
Enter ".help" for usage hints.
sqlite> CREATE TABLE projects (JOB_ID INTEGER PRIMARY KEY AUTOINCREMENT, JOB_NAME TEXT UNIQUE NOT NULL, SCM_REPO TEXT NOT NULL, BRANCH TEXT NOT NULL, PROJ_TOKEN TEXT, YUM_REPO TEXT, USER INTEGER, SCRATCH_BUILD INTEGER DEFAULT 1, WEBHOOK_URL TEXT NOT NULL, BUILD_TAG TEXT, OS TEXT, VERSION TEXT, BUILD_TYPE TEXT, PACKAGE_NAME TEXT);

sqlite> CREATE TABLE users (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT UNIQUE NOT NULL, EMAIL TEXT, API_TOKEN TEXT, USER_PUBKEY TEXT, REPO_PREFIX TEXT NOT NULL UNIQUE);

Import user data


[euler_blade@samantha oepkgs_packages_configs]$ tools/oepkgs_djtools import -t user -j users/e/eulerblade.json -d /mnt/storage/repodb/oepkgs.db

Verifying data imported


[euler_blade@samantha oepkgs_packages_configs]$ sqlite3 /mnt/storage/repodb/oepkgs.db
SQLite version 3.30.0 2019-10-04 15:03:17
Enter ".help" for usage hints.
sqlite> .header on
sqlite> .mode colum
sqlite> SELECT * FROM users;
ID          NAME        EMAIL                         API_TOKEN   USER_PUBKEY                               REPO_PREFIX
----------  ----------  ----------------------------  ----------  ----------------------------------------  ----------------------------
1           eulerblade  euler_blade@isrc.iscas.ac.cn              E0230505E0D0D2948050CADD964617B09C96FB5E  https://gitee.com/eulerblade

Reset user password

[euler_blade@samantha oepkgs_packages_configs]$ tools/oepkgs_djtools passreset -j users/e/eulerblade.json -d /mnt/storage/repodb/oepkgs.db -p newpass

Initializing WebHook token

This step is add temporary, because the string got by Jenkins cli tool is different from Jenkins Web page.

**Admin open oepkgs_template on Jenkins. As picture shows below, click Generate button to generate a new WebHook token, remember this string and click Save button to save it. oepkgs.net jobs Jenkins template

Save it to database with oepkgs_djtools sub-command hookset.

$ ./oepkgs_djtools hookset -d path/to/database/file -u USERNAME -t TOKEN_STRING

Copyright © oepkgs.net All rights reserved.

版权所有 © oepkgs.net 保留所有权利

中国科学院软件研究所openEuler 社区共同发起并提供支持

京ICP备05046678号-13

Email: support(at)oepkgs.net