added config
parent
7f616765b1
commit
13b6c2d111
@ -1,4 +1,7 @@
|
|||||||
#!/usr/bin/env fish
|
#!/usr/bin/env fish
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
OVERWRITE=false
|
OVERWRITE=false
|
||||||
cat etc-file.txt >> /opt/etc/etc-file.txt
|
if $RUN
|
||||||
|
cat etc-file.txt >> /etc/etc-file.txt
|
||||||
|
end
|
||||||
|
export RUN=1
|
@ -0,0 +1,26 @@
|
|||||||
|
use std::fs::File;
|
||||||
|
use toml::value::{Array, Table};
|
||||||
|
use serde_derive::{Serialize, Deserialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub(crate) struct Config {
|
||||||
|
pub(crate) base_package_path: String,
|
||||||
|
pub(crate) installation_path: String,
|
||||||
|
pub(crate) key_verification: bool
|
||||||
|
}
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Config {
|
||||||
|
base_package_path: "/packages".to_string(),
|
||||||
|
installation_path: "/var/gaypk/".to_string(),
|
||||||
|
key_verification: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub(crate) fn read_config() -> Config {
|
||||||
|
toml::from_str("/cfg/gaypk/config.toml").expect("Parse failed!")
|
||||||
|
}
|
||||||
|
pub(crate) fn write_config(cfg: Config) {
|
||||||
|
let file = File::create(crate::config::read_config().installation_path + "config.toml").expect("Failed to read file");
|
||||||
|
writeln!(file, toml::to_string_pretty(&cfg).expect("Write failed!"));
|
||||||
|
}
|
Loading…
Reference in New Issue