add repair fs config option

This commit is contained in:
glyph 2022-02-02 14:49:36 +02:00
parent 33604ac0dc
commit a46b58b206
3 changed files with 17 additions and 53 deletions

View File

@ -49,6 +49,8 @@ pub struct SbotConfigForm {
nounixsock: bool,
/// Run the go-sbot on system start-up (systemd service enabled).
startup: bool,
/// Attempt to repair the filesystem before starting.
repair: bool,
}
// HELPERS AND ROUTES FOR /settings/scuttlebutt
@ -123,6 +125,7 @@ pub fn configure_sbot_post(config: Form<SbotConfigForm>, _auth: Authenticated) -
enable_ebt: owned_config.enable_ebt,
promisc: owned_config.promisc,
nounixsock: owned_config.nounixsock,
repair: owned_config.repair,
};
match owned_config.startup {
@ -239,50 +242,9 @@ pub fn restart_sbot(_auth: Authenticated) -> Flash<Redirect> {
/// Executes a systemctl command for the go-sbot.service process.
pub fn systemctl_sbot_cmd(cmd: &str) -> io::Result<Output> {
//info!("Disabling go-sbot.service");
Command::new("systemctl")
.arg("--user")
.arg(cmd)
.arg("go-sbot.service")
.output()
}
/// Executes a systemctl disable command for the go-sbot.service process.
pub fn disable_sbot_cmd() -> io::Result<Output> {
info!("Disabling go-sbot.service");
Command::new("systemctl")
.arg("--user")
.arg("disable")
.arg("go-sbot.service")
.output()
}
/// Executes a systemctl enable command for the go-sbot.service process.
pub fn enable_sbot_cmd() -> io::Result<Output> {
info!("Enabling go-sbot.service");
Command::new("systemctl")
.arg("--user")
.arg("enable")
.arg("go-sbot.service")
.output()
}
/// Executes a systemctl start command for the go-sbot.service process.
pub fn start_sbot_cmd() -> io::Result<Output> {
info!("Starting go-sbot.service");
Command::new("systemctl")
.arg("--user")
.arg("start")
.arg("go-sbot.service")
.output()
}
/// Executes a systemctl stop command for the go-sbot.service process.
pub fn stop_sbot_cmd() -> io::Result<Output> {
info!("Stopping go-sbot.service");
Command::new("systemctl")
.arg("--user")
.arg("stop")
.arg("go-sbot.service")
.output()
}

View File

@ -14,8 +14,8 @@
{%- endif -%}
<!-- SBOT CONFIGURATION FORM -->
<div class="card center">
<form id="sbotConfig" action="/settings/scuttlebutt/configure" method="post">
<div class="center" style="display: flex; flex-direction: column; width: 80%;" title="Number of hops to replicate">
<form id="sbotConfig" class="center" action="/settings/scuttlebutt/configure" method="post">
<div class="center" style="display: flex; flex-direction: column;" title="Number of hops to replicate">
<label for="hops" class="label-small">HOPS</label>
<div id="hops" style="display: flex; justify-content: space-evenly;">
<input type="radio" id="hops_0" name="hops" value="0"{% if hops == 0 %} checked{% endif %}>
@ -31,7 +31,7 @@
</div>
</div>
<br>
<div class="center" style="display: flex; justify-content: space-between; width: 80%;">
<div class="center" style="display: flex; justify-content: space-between;">
<div style="display: flex; flex-direction: column; width: 60%;" title="IP address on which the sbot runs">
<label for="ip" class="label-small">IP ADDRESS</label>
<input type="text" id="ip" name="lis_ip" value="{{ listen_addr.0 }}">
@ -42,25 +42,28 @@
</div>
</div>
<br>
<div class="center" style="display: flex; flex-direction: column; width: 80%;" title="Network key (aka 'caps key') to define the Scuttleverse in which the sbot operates in">
<div class="center" style="display: flex; flex-direction: column;" title="Network key (aka 'caps key') to define the Scuttleverse in which the sbot operates in">
<label for="network_key" class="label-small">NETWORK KEY</label>
<input type="text" id="network_key" name="shscap" value="{{ sbot_config.shscap }}">
</div>
<br>
<div class="center" style="display: flex; flex-direction: column; width: 80%;" title="Directory in which the sbot database is saved">
<div class="center" style="display: flex; flex-direction: column;" title="Directory in which the sbot database is saved">
<label for="database_dir" class="label-small">DATABASE DIRECTORY</label>
<input type="text" id="database_dir" name="repo" value="{{ sbot_config.repo }}">
</div>
<br>
<div class="center" style="width: 80%;" title="Broadcast the IP and port of this sbot instance so that local peers can discovery it and attempt to connect">
<div class="center">
<input type="checkbox" id="lanBroadcast" name="localadv"{% if sbot_config.localadv == true %} checked{% endif %}>
<label for="lanBroadcast">Enable LAN Broadcasting</label><br>
<label for="lanBroadcast" title="Broadcast the IP and port of this sbot instance so that local peers can discovery it and attempt to connect">Enable LAN Broadcasting</label><br>
<br>
<input type="checkbox" id="lanDiscovery" name="localdiscov" title="Listen for the presence of local peers and attempt to connect if found"{% if sbot_config.localdiscov == true %} checked{% endif %}>
<label for="lanDiscovery">Enable LAN Discovery</label><br>
<input type="checkbox" id="lanDiscovery" name="localdiscov"{% if sbot_config.localdiscov == true %} checked{% endif %}>
<label for="lanDiscovery" title="Listen for the presence of local peers and attempt to connect if found">Enable LAN Discovery</label><br>
<br>
<input type="checkbox" id="startup" name="startup" title="Define whether the pub runs automatically on system startup"{% if run_on_startup == "enabled" %} checked{% endif %}>
<label for="startup">Run pub on system startup</label><br>
<input type="checkbox" id="startup" name="startup"{% if run_on_startup == "enabled" %} checked{% endif %}>
<label for="startup" title="Run the pub automatically on system startup">Run pub on system startup</label><br>
<br>
<input type="checkbox" id="repair" name="repair"{% if sbot_config.repair == true %} checked{% endif %}>
<label for="repair" title="Attempt to repair the filesystem before starting the pub">Attempt filesystem repair when pub starts</label><br>
</div>
<br>
<!-- hidden input elements for all other config variables -->

View File

@ -12,7 +12,6 @@
<a id="start" class="button button-primary center" href="/settings/scuttlebutt/start" title="Start Sbot">Start Sbot</a>
{% endif %}
<a id="checkFilesystem" class="button button-primary center" href="/settings/scuttlebutt/check_fs" title="Check Filesystem">Check Filesystem</a>
<a id="repairFilesystem" class="button button-primary center" href="/settings/scuttlebutt/repair" title="Repair Filesystem">Repair Filesystem</a>
<a id="removeFeeds" class="button button-primary center" href="/settings/scuttlebutt/remove_feeds" title="Remove Blocked Feeds">Remove Blocked Feeds</a>
</div>
<!-- FLASH MESSAGE -->