4 Commits

Author SHA1 Message Date
86e403be19 Disabled cgo since this avoids glibc version errors 2021-12-26 13:03:57 +01:00
c73bdd5b51 Updated install oneliner 2021-12-26 12:59:05 +01:00
90da7b4999 Removed compiler warnings 2021-12-21 12:10:36 +01:00
73c24e457a Fixed logfile no permissions 2021-12-21 12:09:25 +01:00
9 changed files with 18 additions and 32 deletions

View File

@ -1,4 +1,4 @@
VERSION=0.1.0 VERSION=0.1.2
BUILDDIR = . BUILDDIR = .
_BUILDDIR = $(shell realpath $(BUILDDIR))/ _BUILDDIR = $(shell realpath $(BUILDDIR))/
@ -6,7 +6,7 @@ _BUILDDIR = $(shell realpath $(BUILDDIR))/
build: build-server build-container build-extra build: build-server build-container build-extra
build-server: build-server:
cd server/ && go build -o $(_BUILDDIR)/docker4ssh cd server/ && CGO_ENABLED=0 go build -o $(_BUILDDIR)/docker4ssh
build-container: DEBUG=false build-container: DEBUG=false
build-container: build-container:
@ -67,6 +67,8 @@ install:
install -Dm644 $(_BUILDDIR)profile/* -t $(DESTDIR)/etc/docker4ssh/profile/ install -Dm644 $(_BUILDDIR)profile/* -t $(DESTDIR)/etc/docker4ssh/profile/
install -Dm644 $(_BUILDDIR)LICENSE $(DESTDIR)/etc/docker4ssh/LICENSE install -Dm644 $(_BUILDDIR)LICENSE $(DESTDIR)/etc/docker4ssh/LICENSE
touch $(DESTDIR)/etc/docker4ssh/docker4ssh.log && chmod 777 $(DESTDIR)/etc/docker4ssh/docker4ssh.log
uninstall: uninstall:
rm -rf $(DESTDIR)/etc/docker4ssh/ rm -rf $(DESTDIR)/etc/docker4ssh/
rm -f $(DESTDIR)$(PREFIX)/bin/docker4ssh rm -f $(DESTDIR)$(PREFIX)/bin/docker4ssh

View File

@ -51,7 +51,7 @@ For every install method your OS **must** be linux and docker has to be installe
Replace the `RELEASE` value in the following oneliner with the latest release [version](https://github.com/ByteDream/docker4ssh/releases/latest). Replace the `RELEASE` value in the following oneliner with the latest release [version](https://github.com/ByteDream/docker4ssh/releases/latest).
```shell ```shell
$ RELEASE=<latest version> curl -L https://github.com/ByteDream/docker4ssh/releases/download/v$RELEASE/docker4ssh-$RELEASE.tar.gz | tar -xvzf - -C / $ export RELEASE=<latest version> && curl -L https://github.com/ByteDream/docker4ssh/releases/download/v$RELEASE/docker4ssh-$RELEASE.tar.gz | tar -xvzf - -C /
- Building from source - Building from source
Before start installing, make sure you have to following things ready: Before start installing, make sure you have to following things ready:
@ -104,4 +104,4 @@ For further information, visit the [wiki](https://github.com/ByteDream/docker4ss
## ⚖ License ## ⚖ License
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the [LICENSE](LICENSE) file for more details. This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the [LICENSE](LICENSE) file for more details.

View File

@ -1,7 +1,4 @@
use std::fmt::{Debug, format}; use std::process::Command;
use std::net::TcpStream;
use std::os::unix::process::ExitStatusExt;
use std::process::{Command, ExitStatus};
use std::time::SystemTime; use std::time::SystemTime;
use log::{info, warn}; use log::{info, warn};
use structopt::StructOpt; use structopt::StructOpt;
@ -9,7 +6,7 @@ use structopt::clap::AppSettings;
use crate::configure::cli::parser; use crate::configure::cli::parser;
use crate::shared::api::api::API; use crate::shared::api::api::API;
use crate::shared::api::request; use crate::shared::api::request;
use crate::shared::api::request::{ConfigGetResponse, ConfigNetworkMode, ConfigPostRequest, ConfigRunLevel}; use crate::shared::api::request::{ConfigGetResponse, ConfigNetworkMode, ConfigRunLevel};
type Result<T> = std::result::Result<T, failure::Error>; type Result<T> = std::result::Result<T, failure::Error>;
@ -24,9 +21,6 @@ trait Execute {
settings = &[AppSettings::ArgRequiredElseHelp] settings = &[AppSettings::ArgRequiredElseHelp]
)] )]
struct Opts { struct Opts {
#[structopt(short, long, global = true, help = "Verbose output")]
verbose: bool,
#[structopt(subcommand)] #[structopt(subcommand)]
commands: Option<Root> commands: Option<Root>
} }
@ -259,7 +253,7 @@ enum Root {
pub fn cli(route: String) { pub fn cli(route: String) {
if let Some(subcommand) = Opts::from_args().commands { if let Some(subcommand) = Opts::from_args().commands {
let mut result: Result<()> = Ok(()); let mut result: Result<()> = Ok(());
let mut api = API::new(route, String::new()); let mut api = API::new(route);
match subcommand { match subcommand {
Root::Auth(auth) => { Root::Auth(auth) => {
if let Some(subsubcommand) = auth.commands { if let Some(subsubcommand) = auth.commands {

View File

@ -1,5 +1,3 @@
use std::f32::consts::E;
use std::fmt::format;
use crate::shared::api::request::{ConfigNetworkMode, ConfigRunLevel}; use crate::shared::api::request::{ConfigNetworkMode, ConfigRunLevel};
pub fn parse_network_mode(src: &str) -> Result<ConfigNetworkMode, String> { pub fn parse_network_mode(src: &str) -> Result<ConfigNetworkMode, String> {

View File

@ -1,13 +1,13 @@
use std::fs; use std::fs;
use std::net::TcpStream;
use std::os::unix::net::UnixStream;
use std::process::exit; use std::process::exit;
use log::{LevelFilter, trace, warn, info, error}; use log::{LevelFilter, error};
use docker4ssh::configure::cli; use docker4ssh::configure::cli;
use docker4ssh::shared::logging::init_logger; use docker4ssh::shared::logging::init_logger;
fn main() { fn main() {
init_logger(LevelFilter::Debug); if init_logger(LevelFilter::Debug).is_err() {
println!("Failed to initialize logger");
}
match fs::read_to_string("/etc/docker4ssh") { match fs::read_to_string("/etc/docker4ssh") {
Ok(route) => cli(route), Ok(route) => cli(route),

View File

@ -1,21 +1,18 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::net::TcpStream; use std::net::TcpStream;
use log::Level::Error;
use serde::Deserialize; use serde::Deserialize;
pub type Result<T> = std::result::Result<T, failure::Error>; pub type Result<T> = std::result::Result<T, failure::Error>;
pub struct API { pub struct API {
route: String, route: String,
host: String,
} }
impl API { impl API {
pub const fn new(route: String, host: String) -> Self { pub const fn new(route: String) -> Self {
API { API {
route, route,
host,
} }
} }
@ -86,7 +83,7 @@ impl APIResult {
let result: T = serde_json::from_str(&self.result_body).map_err(|e| { let result: T = serde_json::from_str(&self.result_body).map_err(|e| {
// checks if the error has a body and if so, return it // checks if the error has a body and if so, return it
if self.has_body() { if self.has_body() {
let error: APIError = serde_json::from_str(&self.result_body).unwrap_or_else(|ee| { let error: APIError = serde_json::from_str(&self.result_body).unwrap_or_else(|_| {
APIError{message: format!("could not deserialize response: {}", e.to_string())} APIError{message: format!("could not deserialize response: {}", e.to_string())}
}); });
failure::format_err!("Failed to call '{}': {}", self.request_path, error.message) failure::format_err!("Failed to call '{}': {}", self.request_path, error.message)

View File

@ -1,6 +1,5 @@
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde::de::Unexpected::Str;
use serde_repr::{Deserialize_repr, Serialize_repr}; use serde_repr::{Deserialize_repr, Serialize_repr};
use crate::shared::api::api::{API, Method, Request, Result}; use crate::shared::api::api::{API, Method, Request, Result};

View File

@ -1,9 +1,9 @@
use log::{info, Metadata, Record}; use log::{Metadata, Record};
pub struct Logger; pub struct Logger;
impl log::Log for Logger { impl log::Log for Logger {
fn enabled(&self, metadata: &Metadata) -> bool { fn enabled(&self, _metadata: &Metadata) -> bool {
true true
} }
@ -13,7 +13,5 @@ impl log::Log for Logger {
} }
} }
fn flush(&self) { fn flush(&self) {}
todo!()
}
} }

View File

@ -4,8 +4,6 @@ pub mod logger;
pub use logger::Logger; pub use logger::Logger;
static LOGGER: Logger = Logger;
pub fn init_logger(level: LevelFilter) -> Result<(), SetLoggerError> { pub fn init_logger(level: LevelFilter) -> Result<(), SetLoggerError> {
log::set_logger(&Logger).map(|()| log::set_max_level(level)) log::set_logger(&Logger).map(|()| log::set_max_level(level))
} }