Browse Source

add PKGBUILD, and search for config in /etc

master
η (eta) 2 years ago
parent
commit
2b6ef601eb
  1. 32
      PKGBUILD
  2. 22
      src/main.rs

32
PKGBUILD

@ -0,0 +1,32 @@
# Maintainer: eta <eta@theta.eu.org>
pkgname=sms-irc-git
pkgver=r138.e62a533
pkgrel=1
pkgdesc="A WhatsApp Web and SMS bridge for internet relay chat (IRC)."
arch=('x86_64')
url="https://git.theta.eu.org/sms-irc.git/about/"
license=('AGPL3')
depends=('postgresql-libs')
makedepends=('rust' 'cargo')
provides=('sms-irc')
conflicts=('sms-irc')
backup=('etc/sms-irc.conf')
optdepends=('inspircd: IRC server to bridge into')
options=()
changelog=
source=('git+https://git.theta.eu.org/sms-irc.git/')
md5sums=('SKIP')
noextract=()
_gitname="sms-irc"
pkgver() {
cd "$srcdir/$_gitname"
printf "r%s.%s" $(git rev-list --count HEAD) $(git rev-parse --short HEAD)
}
package() {
cd "$srcdir/$_gitname"
install -Dm644 config.example.toml "$pkgdir/etc/sms-irc.conf"
cargo install --path . --root="$pkgdir/usr" --locked
rm "$pkgdir/usr/.crates.toml"
}

22
src/main.rs

@ -39,6 +39,7 @@ use tokio_core::reactor::Core;
use crate::insp_s2s::InspLink;
use crate::whatsapp::WhatsappManager;
use tokio_signal::unix::{Signal, SIGHUP};
use std::path::Path;
fn main() -> Result<(), failure::Error> {
eprintln!("[*] sms-irc version {}", env!("CARGO_PKG_VERSION"));
@ -46,10 +47,25 @@ fn main() -> Result<(), failure::Error> {
let config_path = ::std::env::var("SMSIRC_CONFIG");
let is_def = config_path.is_ok();
let config_path = config_path
.unwrap_or("config.toml".to_string());
let config_path = match config_path {
Ok(p) => p,
_ => {
if Path::new("config.toml").exists() {
"config.toml".to_string()
}
else if Path::new("/etc/sms-irc.conf").exists() {
"/etc/sms-irc.conf".to_string()
}
else {
eprintln!("[!] *** I can't find a configuration file! ***");
eprintln!("[!] Please place one either at ./config.toml or /etc/sms-irc.conf...");
eprintln!("[!] ...or set the SMSIRC_CONFIG environment variable to point to one!");
panic!("Cannot find a configuration file!");
}
}
};
eprintln!("[+] Reading configuration file from file '{}'...", config_path);
if is_def {
if !is_def {
eprintln!("[*] (Set the SMSIRC_CONFIG environment variable to change this.)");
}
let config: Config = toml::from_str(&::std::fs::read_to_string(config_path)?)?;

Loading…
Cancel
Save