merge changes from main
continuous-integration/drone/pr Build is failing
Details
continuous-integration/drone/pr Build is failing
Details
This commit is contained in:
commit
11e94fa421
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,5 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
members = [
|
members = [
|
||||||
"peach-buttons",
|
|
||||||
"peach-oled",
|
"peach-oled",
|
||||||
"peach-lib",
|
"peach-lib",
|
||||||
"peach-config",
|
"peach-config",
|
||||||
|
@ -13,3 +11,4 @@ members = [
|
||||||
"peach-jsonrpc-server",
|
"peach-jsonrpc-server",
|
||||||
"peach-dyndns-updater"
|
"peach-dyndns-updater"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
use peach_lib::config_manager::get_config_value;
|
use peach_lib::config_manager;
|
||||||
|
|
||||||
use crate::error::PeachConfigError;
|
use crate::error::PeachConfigError;
|
||||||
use crate::utils::cmd;
|
use crate::utils::cmd;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref PEACH_CONFIGDIR: String = get_config_value("PEACH_CONFIGDIR")
|
pub static ref PEACH_CONFIGDIR: String = config_manager::get_config_value("PEACH_CONFIGDIR")
|
||||||
.expect("Failed to load config value for PEACH_CONFIGDIR");
|
.expect("Failed to load config value for PEACH_CONFIGDIR");
|
||||||
pub static ref PEACH_WEBDIR: String =
|
pub static ref PEACH_WEBDIR: String = config_manager::get_config_value("PEACH_WEBDIR")
|
||||||
get_config_value("PEACH_WEBDIR").expect("Failed to load config value for PEACH_WEBDIR");
|
.expect("Failed to load config value for PEACH_WEBDIR");
|
||||||
pub static ref PEACH_HOMEDIR: String =
|
pub static ref PEACH_HOMEDIR: String = config_manager::get_config_value("PEACH_HOMEDIR")
|
||||||
get_config_value("PEACH_HOMEDIR").expect("Failed to load config value for PEACH_HOMEDIR");
|
.expect("Failed to load config value for PEACH_HOMEDIR");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Utility function to set correct file permissions on the PeachCloud device.
|
/// Utility function to set correct file permissions on the PeachCloud device.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "peach-lib"
|
name = "peach-lib"
|
||||||
version = "1.3.3"
|
version = "1.3.4"
|
||||||
authors = ["Andrew Reid <glyph@mycelial.technology>"]
|
authors = ["Andrew Reid <glyph@mycelial.technology>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ pub fn get_peach_config_defaults() -> HashMap<String, String> {
|
||||||
("ADMIN_PASSWORD_HASH", "47"),
|
("ADMIN_PASSWORD_HASH", "47"),
|
||||||
("TEMPORARY_PASSWORD_HASH", ""),
|
("TEMPORARY_PASSWORD_HASH", ""),
|
||||||
("GO_SBOT_DATADIR", "/home/peach/.ssb-go"),
|
("GO_SBOT_DATADIR", "/home/peach/.ssb-go"),
|
||||||
|
("GO_SBOT_SERVICE", "go-sbot.service"),
|
||||||
("PEACH_CONFIGDIR", "/var/lib/peachcloud"),
|
("PEACH_CONFIGDIR", "/var/lib/peachcloud"),
|
||||||
("PEACH_HOMEDIR", "/home/peach"),
|
("PEACH_HOMEDIR", "/home/peach"),
|
||||||
("PEACH_WEBDIR", "/usr/share/peach-web"),
|
("PEACH_WEBDIR", "/usr/share/peach-web"),
|
||||||
|
@ -131,7 +132,10 @@ pub fn save_peach_config_to_disc(
|
||||||
peach_config: HashMap<String, String>,
|
peach_config: HashMap<String, String>,
|
||||||
) -> Result<HashMap<String, String>, PeachError> {
|
) -> Result<HashMap<String, String>, PeachError> {
|
||||||
// use a file lock to avoid race conditions while saving config
|
// use a file lock to avoid race conditions while saving config
|
||||||
let mut lock = LockFile::open(&*LOCK_FILE_PATH)?;
|
let mut lock = LockFile::open(&*LOCK_FILE_PATH).map_err(|source| PeachError::Read {
|
||||||
|
source,
|
||||||
|
path: LOCK_FILE_PATH.to_string(),
|
||||||
|
})?;
|
||||||
lock.lock()?;
|
lock.lock()?;
|
||||||
|
|
||||||
// first convert Hashmap to BTreeMap (so that keys are saved in deterministic alphabetical order)
|
// first convert Hashmap to BTreeMap (so that keys are saved in deterministic alphabetical order)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::{fs, fs::File, io, io::Write, path::PathBuf, process::Command, str};
|
use std::{fs, fs::File, io, io::Write, path::PathBuf, process::Command, str};
|
||||||
|
|
||||||
use crate::config_manager::get_config_value;
|
use crate::config_manager;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::error::PeachError;
|
use crate::error::PeachError;
|
||||||
|
@ -67,7 +67,7 @@ impl SbotStatus {
|
||||||
// because non-privileged users are able to run systemctl show
|
// because non-privileged users are able to run systemctl show
|
||||||
let info_output = Command::new("systemctl")
|
let info_output = Command::new("systemctl")
|
||||||
.arg("show")
|
.arg("show")
|
||||||
.arg("go-sbot.service")
|
.arg(config_manager::get_config_value("GO_SBOT_SERVICE")?)
|
||||||
.arg("--no-page")
|
.arg("--no-page")
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ impl SbotStatus {
|
||||||
// because non-privileged users are able to run systemctl status
|
// because non-privileged users are able to run systemctl status
|
||||||
let status_output = Command::new("systemctl")
|
let status_output = Command::new("systemctl")
|
||||||
.arg("status")
|
.arg("status")
|
||||||
.arg("go-sbot.service")
|
.arg(config_manager::get_config_value("GO_SBOT_SERVICE")?)
|
||||||
.output()?;
|
.output()?;
|
||||||
|
|
||||||
let service_status = str::from_utf8(&status_output.stdout)?;
|
let service_status = str::from_utf8(&status_output.stdout)?;
|
||||||
|
@ -128,7 +128,10 @@ impl SbotStatus {
|
||||||
}
|
}
|
||||||
|
|
||||||
// get path to blobstore
|
// get path to blobstore
|
||||||
let blobstore_path = format!("{}/blobs/sha256", get_config_value("GO_SBOT_DATADIR")?);
|
let blobstore_path = format!(
|
||||||
|
"{}/blobs/sha256",
|
||||||
|
config_manager::get_config_value("GO_SBOT_DATADIR")?
|
||||||
|
);
|
||||||
|
|
||||||
// determine the size of the blobstore directory in bytes
|
// determine the size of the blobstore directory in bytes
|
||||||
status.blobstore = dir_size(blobstore_path).ok();
|
status.blobstore = dir_size(blobstore_path).ok();
|
||||||
|
@ -199,9 +202,11 @@ impl Default for SbotConfig {
|
||||||
impl SbotConfig {
|
impl SbotConfig {
|
||||||
/// Read the go-sbot `config.toml` file from file and deserialize into `SbotConfig`.
|
/// Read the go-sbot `config.toml` file from file and deserialize into `SbotConfig`.
|
||||||
pub fn read() -> Result<Self, PeachError> {
|
pub fn read() -> Result<Self, PeachError> {
|
||||||
// determine path of user's home directory
|
// determine path of user's go-sbot config.toml
|
||||||
let mut config_path = dirs::home_dir().ok_or(PeachError::HomeDir)?;
|
let config_path = format!(
|
||||||
config_path.push(".ssb-go/config.toml");
|
"{}/config.toml",
|
||||||
|
config_manager::get_config_value("GO_SBOT_DATADIR")?
|
||||||
|
);
|
||||||
|
|
||||||
let config_contents = fs::read_to_string(config_path)?;
|
let config_contents = fs::read_to_string(config_path)?;
|
||||||
|
|
||||||
|
@ -217,8 +222,11 @@ impl SbotConfig {
|
||||||
// convert the provided `SbotConfig` instance to a string
|
// convert the provided `SbotConfig` instance to a string
|
||||||
let config_string = toml::to_string(&config)?;
|
let config_string = toml::to_string(&config)?;
|
||||||
|
|
||||||
// determine path of user's home directory
|
// determine path of user's go-sbot config.toml
|
||||||
let config_path = format!("{}/config.toml", get_config_value("GO_SBOT_DATADIR")?);
|
let config_path = format!(
|
||||||
|
"{}/config.toml",
|
||||||
|
config_manager::get_config_value("GO_SBOT_DATADIR")?
|
||||||
|
);
|
||||||
|
|
||||||
// open config file for writing
|
// open config file for writing
|
||||||
let mut file = File::create(config_path)?;
|
let mut file = File::create(config_path)?;
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub fn build_template(request: &Request) -> PreEscaped<String> {
|
||||||
form id="sendPasswordReset" action="/auth/temporary" method="post" {
|
form id="sendPasswordReset" action="/auth/temporary" method="post" {
|
||||||
div id="buttonDiv" {
|
div id="buttonDiv" {
|
||||||
input class="button button-primary center" style="margin-top: 1rem;" type="submit" value="Send Temporary Password" title="Send temporary password to Scuttlebutt admin(s)";
|
input class="button button-primary center" style="margin-top: 1rem;" type="submit" value="Send Temporary Password" title="Send temporary password to Scuttlebutt admin(s)";
|
||||||
a href="/auth/reset_password" class="button button-primary center" title="Set a new password using the temporary password" {
|
a href="/auth/reset" class="button button-primary center" title="Set a new password using the temporary password" {
|
||||||
"Set New Password"
|
"Set New Password"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
fs,
|
fs,
|
||||||
fs::File,
|
fs::File,
|
||||||
io,
|
|
||||||
io::prelude::*,
|
io::prelude::*,
|
||||||
path::Path,
|
path::Path,
|
||||||
process::{Command, Output},
|
process::{Command, Output},
|
||||||
|
@ -16,6 +15,7 @@ use golgi::{
|
||||||
api::friends::RelationshipQuery, blobs, messages::SsbMessageValue, sbot::Keystore, Sbot,
|
api::friends::RelationshipQuery, blobs, messages::SsbMessageValue, sbot::Keystore, Sbot,
|
||||||
};
|
};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
|
use peach_lib::config_manager;
|
||||||
use peach_lib::sbot::SbotConfig;
|
use peach_lib::sbot::SbotConfig;
|
||||||
use rouille::input::post::BufferedFile;
|
use rouille::input::post::BufferedFile;
|
||||||
use temporary::Directory;
|
use temporary::Directory;
|
||||||
|
@ -25,12 +25,13 @@ use crate::{error::PeachWebError, utils::sbot};
|
||||||
// SBOT HELPER FUNCTIONS
|
// SBOT HELPER FUNCTIONS
|
||||||
|
|
||||||
/// Executes a systemctl command for the go-sbot.service process.
|
/// Executes a systemctl command for the go-sbot.service process.
|
||||||
pub fn systemctl_sbot_cmd(cmd: &str) -> io::Result<Output> {
|
pub fn systemctl_sbot_cmd(cmd: &str) -> Result<Output, PeachWebError> {
|
||||||
Command::new("sudo")
|
let output = Command::new("sudo")
|
||||||
.arg("systemctl")
|
.arg("systemctl")
|
||||||
.arg(cmd)
|
.arg(cmd)
|
||||||
.arg("go-sbot.service")
|
.arg(config_manager::get_config_value("GO_SBOT_SERVICE")?)
|
||||||
.output()
|
.output()?;
|
||||||
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes a systemctl stop command followed by start command.
|
/// Executes a systemctl stop command followed by start command.
|
||||||
|
@ -68,15 +69,18 @@ pub async fn init_sbot_with_config(
|
||||||
) -> Result<Sbot, PeachWebError> {
|
) -> Result<Sbot, PeachWebError> {
|
||||||
debug!("Initialising an sbot client with configuration parameters");
|
debug!("Initialising an sbot client with configuration parameters");
|
||||||
// initialise sbot connection with ip:port and shscap from config file
|
// initialise sbot connection with ip:port and shscap from config file
|
||||||
|
let key_path = format!(
|
||||||
|
"{}/secret",
|
||||||
|
config_manager::get_config_value("GO_SBOT_DATADIR")?
|
||||||
|
);
|
||||||
let sbot_client = match sbot_config {
|
let sbot_client = match sbot_config {
|
||||||
// TODO: panics if we pass `Some(conf.shscap)` as second arg
|
// TODO: panics if we pass `Some(conf.shscap)` as second arg
|
||||||
Some(conf) => {
|
Some(conf) => {
|
||||||
let ip_port = conf.lis.clone();
|
let ip_port = conf.lis.clone();
|
||||||
Sbot::init(Keystore::GoSbot, Some(ip_port), None).await?
|
Sbot::init(Keystore::CustomGoSbot(key_path), Some(ip_port), None).await?
|
||||||
}
|
}
|
||||||
None => Sbot::init(Keystore::GoSbot, None, None).await?,
|
None => Sbot::init(Keystore::CustomGoSbot(key_path), None, None).await?,
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(sbot_client)
|
Ok(sbot_client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue