Change imports and add permissions for peach-web dir
This commit is contained in:
parent
570f6a679b
commit
62793f401e
|
@ -2,7 +2,6 @@ use crate::error::PeachConfigError;
|
||||||
use crate::ChangePasswordOpts;
|
use crate::ChangePasswordOpts;
|
||||||
use peach_lib::password_utils::set_new_password;
|
use peach_lib::password_utils::set_new_password;
|
||||||
|
|
||||||
|
|
||||||
/// Utility function to set the admin password for peach-web from the command-line.
|
/// Utility function to set the admin password for peach-web from the command-line.
|
||||||
pub fn set_peach_web_password(opts: ChangePasswordOpts) -> Result<(), PeachConfigError> {
|
pub fn set_peach_web_password(opts: ChangePasswordOpts) -> Result<(), PeachConfigError> {
|
||||||
match opts.password {
|
match opts.password {
|
||||||
|
|
|
@ -2,10 +2,10 @@ mod change_password;
|
||||||
mod constants;
|
mod constants;
|
||||||
mod error;
|
mod error;
|
||||||
mod generate_manifest;
|
mod generate_manifest;
|
||||||
|
mod set_permissions;
|
||||||
mod setup_networking;
|
mod setup_networking;
|
||||||
mod setup_peach;
|
mod setup_peach;
|
||||||
mod setup_peach_deb;
|
mod setup_peach_deb;
|
||||||
mod set_permissions;
|
|
||||||
mod update;
|
mod update;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
@ -14,12 +14,6 @@ use log::error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
|
|
||||||
use crate::change_password::set_peach_web_password;
|
|
||||||
use crate::generate_manifest::generate_manifest;
|
|
||||||
use crate::setup_peach::setup_peach;
|
|
||||||
use crate::update::update;
|
|
||||||
use crate::set_permissions::set_permissions;
|
|
||||||
|
|
||||||
#[derive(StructOpt, Debug)]
|
#[derive(StructOpt, Debug)]
|
||||||
#[structopt(
|
#[structopt(
|
||||||
name = "peach-config",
|
name = "peach-config",
|
||||||
|
@ -119,14 +113,14 @@ fn main() {
|
||||||
if let Some(subcommand) = opt.commands {
|
if let Some(subcommand) = opt.commands {
|
||||||
match subcommand {
|
match subcommand {
|
||||||
PeachConfig::Setup(cfg) => {
|
PeachConfig::Setup(cfg) => {
|
||||||
match setup_peach(cfg.no_input, cfg.default_locale, cfg.i2c, cfg.rtc) {
|
match setup_peach::setup_peach(cfg.no_input, cfg.default_locale, cfg.i2c, cfg.rtc) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("peach-config encountered an error: {}", err)
|
error!("peach-config encountered an error: {}", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PeachConfig::Manifest => match generate_manifest() {
|
PeachConfig::Manifest => match generate_manifest::generate_manifest() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(
|
error!(
|
||||||
|
@ -135,22 +129,24 @@ fn main() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PeachConfig::Update(opts) => match update(opts) {
|
PeachConfig::Update(opts) => match update::update(opts) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("peach-config encountered an error during update: {}", err)
|
error!("peach-config encountered an error during update: {}", err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PeachConfig::ChangePassword(opts) => match set_peach_web_password(opts) {
|
PeachConfig::ChangePassword(opts) => {
|
||||||
Ok(_) => {}
|
match change_password::set_peach_web_password(opts) {
|
||||||
Err(err) => {
|
Ok(_) => {}
|
||||||
error!(
|
Err(err) => {
|
||||||
"peach-config encountered an error during password update: {}",
|
error!(
|
||||||
err
|
"peach-config encountered an error during password update: {}",
|
||||||
)
|
err
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
PeachConfig::SetPermissions => match set_permissions() {
|
PeachConfig::SetPermissions => match set_permissions::set_permissions() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!(
|
error!(
|
||||||
|
@ -158,7 +154,7 @@ fn main() {
|
||||||
err
|
err
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ use crate::utils::cmd;
|
||||||
/// All configs are stored in this folder, and should be read/writeable by peach group
|
/// All configs are stored in this folder, and should be read/writeable by peach group
|
||||||
/// so they can be read and written by all PeachCloud services.
|
/// so they can be read and written by all PeachCloud services.
|
||||||
pub const CONFIGS_DIR: &str = "/var/lib/peachcloud";
|
pub const CONFIGS_DIR: &str = "/var/lib/peachcloud";
|
||||||
|
pub const PEACH_WEB_DIR: &str = "/usr/share/peach-web";
|
||||||
|
|
||||||
/// Utility function to set correct file permissions on the PeachCloud device.
|
/// Utility function to set correct file permissions on the PeachCloud device.
|
||||||
/// Accidentally changing file permissions is a fairly common thing to happen,
|
/// Accidentally changing file permissions is a fairly common thing to happen,
|
||||||
|
@ -13,6 +14,8 @@ pub fn set_permissions() -> Result<(), PeachConfigError> {
|
||||||
cmd(&["chmod", "-R", "u+rwX,g+rwX", CONFIGS_DIR])?;
|
cmd(&["chmod", "-R", "u+rwX,g+rwX", CONFIGS_DIR])?;
|
||||||
cmd(&["chown", "-R", "peach", CONFIGS_DIR])?;
|
cmd(&["chown", "-R", "peach", CONFIGS_DIR])?;
|
||||||
cmd(&["chgrp", "-R", "peach", CONFIGS_DIR])?;
|
cmd(&["chgrp", "-R", "peach", CONFIGS_DIR])?;
|
||||||
|
cmd(&["chmod", "-R", "u+rwX,g+rwX", PEACH_WEB_DIR])?;
|
||||||
|
cmd(&["chown", "-R", "peach-web:peach", PEACH_WEB_DIR])?;
|
||||||
println!("[ PERMISSIONS SUCCESSFULLY UPDATED ]");
|
println!("[ PERMISSIONS SUCCESSFULLY UPDATED ]");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ use crate::update::update_microservices;
|
||||||
use crate::utils::{cmd, conf, create_group_if_doesnt_exist, does_user_exist, get_output};
|
use crate::utils::{cmd, conf, create_group_if_doesnt_exist, does_user_exist, get_output};
|
||||||
use crate::RtcOption;
|
use crate::RtcOption;
|
||||||
|
|
||||||
|
|
||||||
/// Idempotent setup of PeachCloud device which sets up networking configuration,
|
/// Idempotent setup of PeachCloud device which sets up networking configuration,
|
||||||
/// configures the peachcloud apt repository, installs system dependencies,
|
/// configures the peachcloud apt repository, installs system dependencies,
|
||||||
/// installs microservices, and creates necessary system groups and users.
|
/// installs microservices, and creates necessary system groups and users.
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# exit when any command fails
|
||||||
|
set -e
|
||||||
|
|
||||||
|
KEYFILE=/Users/notplants/.ssh/id_rsa
|
||||||
|
SERVICE=peach-dyndns-updater
|
||||||
|
|
||||||
|
# deploy
|
||||||
|
rsync -avzh --exclude target --exclude .idea --exclude .git -e "ssh -i $KEYFILE" . rust@167.99.136.83:/srv/peachcloud/automation/peach-workspace/$SERVICE/
|
||||||
|
rsync -avzh --exclude target --exclude .idea --exclude .git -e "ssh -i $KEYFILE" ~/computer/projects/peachcloud/peach-workspace/peach-lib/ rust@167.99.136.83:/srv/peachcloud/automation/peach-workspace/peach-lib/
|
||||||
|
|
||||||
|
echo "++ cross compiling on vps"
|
||||||
|
BIN_PATH=$(ssh -i $KEYFILE rust@167.99.136.83 'cd /srv/peachcloud/automation/peach-workspace/peach-dyndns-updater; /home/rust/.cargo/bin/cargo clean -p peach-lib; /home/rust/.cargo/bin/cargo build --release --target=aarch64-unknown-linux-gnu')
|
||||||
|
|
||||||
|
echo "++ copying ${BIN_PATH} to local"
|
||||||
|
rm -f target/$SERVICE
|
||||||
|
scp -i $KEYFILE rust@167.99.136.83:/srv/peachcloud/automation/peach-workspace/target/aarch64-unknown-linux-gnu/release/peach-dyndns-updater ../target/vps-bin-$SERVICE
|
||||||
|
|
||||||
|
#echo "++ cross compiling"
|
||||||
|
BINFILE="../target/vps-bin-$SERVICE"
|
||||||
|
echo $BINFILE
|
||||||
|
|
||||||
|
|
||||||
|
echo "++ build successful"
|
||||||
|
|
||||||
|
echo "++ copying to pi"
|
||||||
|
ssh -t -i $KEYFILE peach@peach.link 'mkdir -p /srv/dev/bins'
|
||||||
|
scp -i $KEYFILE $BINFILE peach@peach.link:/srv/dev/bins/$SERVICE
|
||||||
|
|
Loading…
Reference in New Issue