Fix directories and add service files
This commit is contained in:
parent
b66b2cee57
commit
272d950bae
14
7dtd-daemon.service
Normal file
14
7dtd-daemon.service
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Synchronize 7dtd mods
|
||||||
|
After=sysinit.target local-fs.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=4
|
||||||
|
|
||||||
|
ExecStart=/usr/bin/sync-7dtd-daemon
|
||||||
|
|
||||||
|
Environment=RUST_LOG=ERROR
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
60
Cargo.lock
generated
60
Cargo.lock
generated
@ -142,21 +142,6 @@ version = "1.1.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
|
checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "daemon"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"directories",
|
|
||||||
"mod_list",
|
|
||||||
"postcard",
|
|
||||||
"serde",
|
|
||||||
"tokio",
|
|
||||||
"tracing",
|
|
||||||
"tracing-subscriber",
|
|
||||||
"urlencoded",
|
|
||||||
"urlencoding",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_more"
|
name = "derive_more"
|
||||||
version = "0.99.17"
|
version = "0.99.17"
|
||||||
@ -494,21 +479,6 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "41f5c9112cb662acd3b204077e0de5bc66305fa8df65c8019d5adb10e9ab6e58"
|
checksum = "41f5c9112cb662acd3b204077e0de5bc66305fa8df65c8019d5adb10e9ab6e58"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mods-server"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"futures-util",
|
|
||||||
"heapless 0.8.0",
|
|
||||||
"mod_list",
|
|
||||||
"postcard",
|
|
||||||
"serde",
|
|
||||||
"tokio",
|
|
||||||
"tracing",
|
|
||||||
"tracing-subscriber",
|
|
||||||
"urlencoding",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-ansi-term"
|
name = "nu-ansi-term"
|
||||||
version = "0.46.0"
|
version = "0.46.0"
|
||||||
@ -976,6 +946,36 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sync-7dtd-daemon"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"directories",
|
||||||
|
"mod_list",
|
||||||
|
"postcard",
|
||||||
|
"serde",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
"urlencoded",
|
||||||
|
"urlencoding",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "sync-7dtd-server"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"futures-util",
|
||||||
|
"heapless 0.8.0",
|
||||||
|
"mod_list",
|
||||||
|
"postcard",
|
||||||
|
"serde",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
"tracing-subscriber",
|
||||||
|
"urlencoding",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.61"
|
version = "1.0.61"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "daemon"
|
name = "sync-7dtd-daemon"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ async fn main() {
|
|||||||
.expect("Failed to create mod file parent dir");
|
.expect("Failed to create mod file parent dir");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tracing::info!("Writing file: {file_path:?}");
|
||||||
if let Err(e) = tokio::fs::write(file_path, &buffer).await {
|
if let Err(e) = tokio::fs::write(file_path, &buffer).await {
|
||||||
tracing::warn!("Unable to save {f:?}: {e}");
|
tracing::warn!("Unable to save {f:?}: {e}");
|
||||||
break;
|
break;
|
||||||
|
@ -102,14 +102,14 @@ pub async fn refresh_mod_list(dir: PathBuf, mod_list: ModList) -> std::io::Resul
|
|||||||
let Some(name) = f.file_name().to_str().map(String::from) else {
|
let Some(name) = f.file_name().to_str().map(String::from) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let date = meta.modified()?;
|
|
||||||
let mut files = Vec::with_capacity(1024);
|
let mut files = Vec::with_capacity(1024);
|
||||||
|
|
||||||
let file = ModFileInfo {
|
// let date = meta.modified()?;
|
||||||
path: file_relative(&dir_string, f.path()),
|
// let file = ModFileInfo {
|
||||||
ts: date,
|
// path: file_relative(&dir_string, f.path()),
|
||||||
};
|
// ts: date,
|
||||||
files.push(file);
|
// };
|
||||||
|
// files.push(file);
|
||||||
read_rec(&dir_string, f.path(), &mut files)?;
|
read_rec(&dir_string, f.path(), &mut files)?;
|
||||||
|
|
||||||
let newest = files
|
let newest = files
|
||||||
@ -141,12 +141,12 @@ fn read_rec(dir: &str, path: PathBuf, res: &mut Vec<ModFileInfo>) -> std::io::Re
|
|||||||
let f = f?;
|
let f = f?;
|
||||||
let meta = f.metadata()?;
|
let meta = f.metadata()?;
|
||||||
if meta.is_dir() {
|
if meta.is_dir() {
|
||||||
let date = meta.modified()?;
|
// let date = meta.modified()?;
|
||||||
let file = ModFileInfo {
|
// let file = ModFileInfo {
|
||||||
path: file_relative(dir, f.path()),
|
// path: file_relative(dir, f.path()),
|
||||||
ts: date,
|
// ts: date,
|
||||||
};
|
// };
|
||||||
res.push(file);
|
// res.push(file);
|
||||||
read_rec(&dir, f.path(), res)?;
|
read_rec(&dir, f.path(), res)?;
|
||||||
} else if meta.is_file() {
|
} else if meta.is_file() {
|
||||||
let date = meta.modified()?;
|
let date = meta.modified()?;
|
||||||
|
15
server.service
Normal file
15
server.service
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=7dtd sync server
|
||||||
|
After=sysinit.target local-fs.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=4
|
||||||
|
|
||||||
|
ExecStart=/usr/bin/sync-7dtd-server
|
||||||
|
|
||||||
|
Environment=RUST_LOG=ERROR
|
||||||
|
Environment=7DTD_MODS_DIR=/home/7dtd/server/Mods
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
@ -1,5 +1,5 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mods-server"
|
name = "sync-7dtd-server"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user