Skip to content

Commit

Permalink
Fixed workflow, added default iw4m config
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefanuk12 committed May 27, 2023
1 parent 208cba1 commit 6d7432e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ jobs:
with:
# (required) Comma-separated list of binary names (non-extension portion of filename) to build and upload.
# Note that glob pattern is not supported yet.
bin: cod-rcon
bin: plutonium-manager
# (required) GitHub token for uploading assets to GitHub Releases.
token: ${{ secrets.GITHUB_TOKEN }}
22 changes: 22 additions & 0 deletions src/installer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,28 @@ pub async fn install_iw4m(target_dir: Option<&str>) {
zip_extract::extract(Cursor::new(release_zip), &target_dir, true).expect("unable to extract iw4m files");
}

// Installs IW4M
pub async fn install_iw4m_config(target_dir: Option<&str>) {
// Initialise
let target_dir = PathBuf::from(target_dir.unwrap_or("."));
fs::create_dir_all(&target_dir).expect("unable to create installation directory");

// Create a reqwest client
let mut headers = header::HeaderMap::new();
headers.insert("User-Agent", header::HeaderValue::from_static("plutonium-manager"));

let client = reqwest::Client::builder()
.default_headers(headers)
.build()
.unwrap();

// Download the release
let release_zip = download_file(&client, "https://cdn.discordapp.com/attachments/749611171216359474/1108504949836496996/Configuration.zip").await.unwrap();

// Extract
zip_extract::extract(Cursor::new(release_zip), &target_dir, true).expect("unable to extract iw4m files");
}

// Installs IW4M log server
pub async fn install_iw4m_log(target_dir: Option<&str>) {
// Initialise
Expand Down
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ struct Args {
#[arg(short, long, value_name="path")]
iw4m: Option<String>,

/// Install a default IW4M config (you must change it afterwards)
#[arg(short='d', long, value_name="path")]
iw4m_config: Option<String>,

/// Install IW4M Admin (log server) to a given path
#[arg(short='l', long, value_name="path")]
iw4m_log: Option<String>,
Expand Down Expand Up @@ -74,6 +78,13 @@ async fn main() {
installer::install_iw4m(Some(&path)).await;
println!("Installed iw4m files.");
}
if args.iw4m_config.is_some() {
let path = args.iw4m_config.unwrap();

println!("Installing iw4m config to {}.", path);
installer::install_iw4m_config(Some(&path)).await;
println!("Installed iw4m config.");
}
if args.iw4m_log.is_some() {
let path = args.iw4m_log.unwrap();

Expand Down

0 comments on commit 6d7432e

Please sign in to comment.