Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple server mount #41

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ jobs:
if: ${{ Contains(matrix.os, 'windows') }}
shell: pwsh
run: |
$download_url = Invoke-RestMethod -Uri "https://api.github.com/repos/Seagate/cloudfuse/releases/latest" | Select-Object -ExpandProperty assets | Where-Object { $_.name -like "*no_gui_windows_amd64.exe" } | Select-Object -ExpandProperty browser_download_url
$download_url = Invoke-RestMethod -Uri "https://api.github.com/repos/Seagate/cloudfuse/releases/latest" | Select-Object -ExpandProperty assets | Where-Object { $_.name -like "*no_gui" -and $_.name -like "*windows_amd64.exe" } | Select-Object -ExpandProperty browser_download_url
$file_name = $download_url.Split('/')[-1]
Invoke-WebRequest -Uri $download_url -OutFile $file_name

- name: Download cloudfuse for Linux amd64 (no_gui)
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: |
download_url=$(curl -s https://api.github.com/repos/Seagate/cloudfuse/releases/latest | jq -r '.assets[] | select(.name | contains("no_gui_linux_amd64.deb")) | .browser_download_url')
download_url=$(curl -s https://api.github.com/repos/Seagate/cloudfuse/releases/latest | jq -r '.assets[] | select(.name | (contains("no_gui") and contains("linux_amd64.deb"))) | .browser_download_url')
curl -LO $download_url

- name: Download cloudfuse for Linux arm64 (no_gui)
if: ${{ Contains(matrix.os, 'ubuntu') }}
run: |
download_url=$(curl -s https://api.github.com/repos/Seagate/cloudfuse/releases/latest | jq -r '.assets[] | select(.name | contains("no_gui_linux_arm64.deb")) | .browser_download_url')
download_url=$(curl -s https://api.github.com/repos/Seagate/cloudfuse/releases/latest | jq -r '.assets[] | select(.name | (contains("no_gui") and contains("linux_arm64.deb"))) | .browser_download_url')
curl -LO $download_url

- name: Run build script for Linux x64
Expand Down
91 changes: 51 additions & 40 deletions src/lib/cloudfuse/child_process_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,60 @@
#include "child_process.h"
#include <fstream>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <unistd.h>

std::string config_template = R"(
allow-other: true
logging:
level: log_err
type: syslog

components:
- libfuse
- file_cache
- attr_cache
- s3storage

libfuse:
attribute-expiration-sec: 1800
entry-expiration-sec: 1800
negative-entry-expiration-sec: 1800
ignore-open-flags: true
network-share: true

file_cache:
path: { 0 }
timeout-sec: 180
allow-non-empty-temp: true
cleanup-on-start: false

attr_cache:
timeout-sec: 3600

s3storage:
bucket-name: { BUCKET_NAME }
endpoint: { ENDPOINT }
region: { AWS_REGION }
)";
std::string getSystemName()
{
std::string systemName;
struct utsname buffer;
if (uname(&buffer) != -1)
{
systemName = buffer.nodename;
}

return systemName;
}

CloudfuseMngr::CloudfuseMngr()
{
std::string systemName = getSystemName();
std::string config_template = R"(
allow-other: true
logging:
level: log_err
type: syslog

components:
- libfuse
- file_cache
- attr_cache
- s3storage

libfuse:
attribute-expiration-sec: 1800
entry-expiration-sec: 1800
negative-entry-expiration-sec: 1800
ignore-open-flags: true
network-share: true

file_cache:
path: { 0 }
timeout-sec: 180
allow-non-empty-temp: true
cleanup-on-start: false

attr_cache:
timeout-sec: 3600

s3storage:
bucket-name: { BUCKET_NAME }
endpoint: { ENDPOINT }
region: { AWS_REGION }
subdirectory: )" + systemName +
"\n";

std::string homeEnv;
const char *home = std::getenv("HOME");
if (home == nullptr)
Expand All @@ -80,13 +95,9 @@ CloudfuseMngr::CloudfuseMngr()
configFile = homeEnv + "/nx_plugin_config.aes";
templateFile = homeEnv + "/nx_plugin_config.yaml";

std::ifstream in(templateFile);
if (!in.good())
{
std::ofstream out(templateFile);
out << config_template;
out.close();
}
std::ofstream out(templateFile, std::ios::trunc);
out << config_template;
out.close();
}

processReturn CloudfuseMngr::spawnProcess(char *const argv[], char *const envp[])
Expand Down
97 changes: 54 additions & 43 deletions src/lib/cloudfuse/child_process_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,42 +41,6 @@ namespace fs = std::filesystem;
#include <fstream>
#include <locale>

std::string config_template = R"(
allow-other: true
logging:
level: log_err
type: syslog

components:
- libfuse
- file_cache
- attr_cache
- s3storage

libfuse:
attribute-expiration-sec: 1800
entry-expiration-sec: 1800
negative-entry-expiration-sec: 1800
ignore-open-flags: true
network-share: true

file_cache:
path: { 0 }
timeout-sec: 180
allow-non-empty-temp: true
cleanup-on-start: false

attr_cache:
timeout-sec: 3600

s3storage:
key-id: { AWS_ACCESS_KEY_ID }
secret-key: { AWS_SECRET_ACCESS_KEY }
bucket-name: { BUCKET_NAME }
endpoint: { ENDPOINT }
region: { AWS_REGION }
)";

// Return available drive letter to mount
std::string getAvailableDriveLetter()
{
Expand All @@ -91,8 +55,59 @@ std::string getAvailableDriveLetter()
return "Z:";
}

std::string getSystemName()
{
std::string systemName;
char computerName[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = sizeof(computerName) / sizeof(char);
if (GetComputerNameA(computerName, &size))
{
systemName = computerName;
}

return systemName;
}

CloudfuseMngr::CloudfuseMngr()
{
std::string systemName = getSystemName();
std::string config_template = R"(
allow-other: true
logging:
level: log_err
type: syslog

components:
- libfuse
- file_cache
- attr_cache
- s3storage

libfuse:
attribute-expiration-sec: 1800
entry-expiration-sec: 1800
negative-entry-expiration-sec: 1800
ignore-open-flags: true
network-share: true

file_cache:
path: { 0 }
timeout-sec: 180
allow-non-empty-temp: true
cleanup-on-start: false

attr_cache:
timeout-sec: 3600

s3storage:
key-id: { AWS_ACCESS_KEY_ID }
secret-key: { AWS_SECRET_ACCESS_KEY }
bucket-name: { BUCKET_NAME }
endpoint: { ENDPOINT }
region: { AWS_REGION }
subdirectory: )" + systemName +
"\n";

std::string appdataEnv;
char *buf = nullptr;
size_t len;
Expand All @@ -116,13 +131,9 @@ CloudfuseMngr::CloudfuseMngr()
configFile = configFilePath.generic_string();
templateFile = templateFilePath.generic_string();

std::ifstream in(templateFile.c_str());
if (!in.good())
{
std::ofstream out(templateFile.c_str());
out << config_template;
out.close();
}
std::ofstream out(templateFile, std::ios::trunc);
out << config_template;
out.close();
}

processReturn CloudfuseMngr::spawnProcess(wchar_t *argv, std::wstring envp)
Expand Down
Loading