Add default configuration file to debian package

This commit is contained in:
silverpill 2022-05-11 21:05:44 +00:00
parent dad9640685
commit 6c675c11c4
5 changed files with 76 additions and 26 deletions

View file

@ -39,7 +39,9 @@ cargo build --release --features production
This command will produce two binaries in `target/release` directory, `mitra` and `mitractl`. This command will produce two binaries in `target/release` directory, `mitra` and `mitractl`.
Create the database and the configuration file (see [example](./config.yaml.example)). Default config file path is `/etc/mitra/config.yaml`, but it can be changed using `CONFIG_PATH` environment variable. Install PostgreSQL and create the database.
Create configuration file by copying `contrib/mitra_config.yaml` and configure the instance. Default config file path is `/etc/mitra/config.yaml`, but it can be changed using `CONFIG_PATH` environment variable.
Start Mitra: Start Mitra:
@ -53,6 +55,24 @@ Building instructions for `mitra-web` frontend can be found at https://codeberg.
To run Mitra as a systemd service, check out the [systemd unit file example](./contrib/mitra.service). To run Mitra as a systemd service, check out the [systemd unit file example](./contrib/mitra.service).
### Debian package
Download and install Mitra package:
```
dpkg -i mitra.deb
```
Install PostgreSQL and create the database. Open configuration file `/etc/mitra/config.yaml` and configure the instance.
Start Mitra:
```
systemctl start mitra
```
An HTTP server will be needed to handle HTTPS requests and serve the frontend. See the example of [nginx configuration file](./contrib/mitra.nginx).
## Development ## Development
### Create database ### Create database

View file

@ -4,35 +4,19 @@ storage_dir: files
http_host: '127.0.0.1' http_host: '127.0.0.1'
http_port: 8380 http_port: 8380
log_level: info instance_uri: 127.0.0.1:8380
instance_title: Mitra
instance_short_description: My instance
instance_description: My instance
registrations_open: true
# Domain name
instance_uri: example.tld
instance_title: example
instance_short_description: my instance
# Long description can contain markdown syntax
instance_description: my instance
registrations_open: false
# EIP-4361 login message
login_message: 'Do not sign this message on other sites!'
post_character_limit: 2000
# Blockchain settings
# Set `blockchain` key to `null` to disable blockchain integration
blockchain: blockchain:
# CAIP-2 chain ID (https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md)
chain_id: eip155:31337 chain_id: eip155:31337
contract_address: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9' contract_address: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9'
contract_dir: contracts contract_dir: contracts
api_url: 'http://127.0.0.1:8545' api_url: 'http://127.0.0.1:8545'
# Block explorer base URL (should be compatible with https://eips.ethereum.org/EIPS/eip-3091)
explorer_url: null explorer_url: null
# Instance private key
signing_key: null signing_key: null
# IPFS settings
# Set `ipfs_api_url` key to `null` to disable IPFS integration
ipfs_api_url: 'http://127.0.0.1:5001' ipfs_api_url: 'http://127.0.0.1:5001'
# IPFS gateway for clients ipfs_gateway_url: 'http://127.0.0.1:8001'
ipfs_gateway_url: 'https://ipfs.io'

42
contrib/mitra_config.yaml Normal file
View file

@ -0,0 +1,42 @@
# Mitra configuration file
database_url: postgres://mitra:mitra@127.0.0.1:5432/mitra
storage_dir: /var/lib/mitra
http_host: '127.0.0.1'
http_port: 8383
# Log level (debug, info, warn)
#log_level: info
# Domain name
instance_uri: example.tld
instance_title: example
instance_short_description: my instance
# Long description can contain markdown syntax
instance_description: my instance
registrations_open: false
# EIP-4361 login message
#login_message: 'Do not sign this message on other sites!'
#post_character_limit: 2000
# Blockchain settings
# Example:
#blockchain:
# chain_id: eip155:31337
# contract_address: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9'
# contract_dir: contracts
# api_url: 'http://127.0.0.1:8545'
# explorer_url: null
# signing_key: null
# Set `blockchain` key to `null` to disable blockchain integration
blockchain: null
# IPFS settings
# Set `ipfs_api_url` key to `null` to disable IPFS integration
ipfs_api_url: null
# IPFS gateway for clients
ipfs_gateway_url: null

View file

@ -19,12 +19,13 @@ echo "Architecture: $ARCH" >> $PACKAGE_DIR/debian/control
# Service # Service
cp contrib/mitra.service $PACKAGE_DIR/debian/mitra.service cp contrib/mitra.service $PACKAGE_DIR/debian/mitra.service
# Config directory # Config file
mkdir -p $PACKAGE_DIR/etc/mitra mkdir -p $PACKAGE_DIR/etc/mitra
cp contrib/mitra_config.yaml $PACKAGE_DIR/etc/mitra/config.yaml
# Config example # Config example
mkdir -p $PACKAGE_DIR/usr/share/mitra/examples mkdir -p $PACKAGE_DIR/usr/share/mitra/examples
cp config.yaml.example $PACKAGE_DIR/usr/share/mitra/examples/config.yaml cp contrib/mitra_config.yaml $PACKAGE_DIR/usr/share/mitra/examples/config.yaml
# Binaries # Binaries
mkdir -p $PACKAGE_DIR/usr/bin mkdir -p $PACKAGE_DIR/usr/bin

View file

@ -80,11 +80,14 @@ fn default_post_character_limit() -> usize { 2000 }
#[derive(Clone, Deserialize)] #[derive(Clone, Deserialize)]
pub struct BlockchainConfig { pub struct BlockchainConfig {
// CAIP-2 chain ID (https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md)
pub chain_id: String, pub chain_id: String,
pub contract_address: String, pub contract_address: String,
pub contract_dir: PathBuf, pub contract_dir: PathBuf,
pub api_url: String, pub api_url: String,
// Block explorer base URL (should be compatible with https://eips.ethereum.org/EIPS/eip-3091)
pub explorer_url: Option<String>, pub explorer_url: Option<String>,
// Instance private key
pub signing_key: String, pub signing_key: String,
} }
@ -122,7 +125,7 @@ pub struct Config {
#[serde(default = "default_log_level")] #[serde(default = "default_log_level")]
pub log_level: LogLevel, pub log_level: LogLevel,
// Instance info // Domain name or <IP address>:<port>
instance_uri: String, instance_uri: String,
pub instance_title: String, pub instance_title: String,
pub instance_short_description: String, pub instance_short_description: String,