Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Vaultwarden
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Vaultwarden
Commits
9859ba63
Unverified
Commit
9859ba63
authored
4 years ago
by
Daniel García
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1443 from jjlin/data-folder
Check for data folder on startup
parents
ebe334fc
513056f7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/api/admin.rs
+2
-2
2 additions, 2 deletions
src/api/admin.rs
src/main.rs
+23
-2
23 additions, 2 deletions
src/main.rs
src/util.rs
+9
-0
9 additions, 0 deletions
src/util.rs
with
34 additions
and
4 deletions
src/api/admin.rs
+
2
−
2
View file @
9859ba63
...
...
@@ -19,7 +19,7 @@ use crate::{
db
::{
backup_database
,
models
::
*
,
DbConn
,
DbConnType
},
error
::{
Error
,
MapResult
},
mail
,
util
::{
format_naive_datetime_local
,
get_display_size
},
util
::{
format_naive_datetime_local
,
get_display_size
,
is_running_in_docker
},
CONFIG
,
};
...
...
@@ -486,7 +486,7 @@ fn diagnostics(_token: AdminToken, _conn: DbConn) -> ApiResult<Html<String>> {
let
web_vault_version
:
WebVaultVersion
=
serde_json
::
from_str
(
&
vault_version_str
)
?
;
// Execute some environment checks
let
running_within_docker
=
std
::
path
::
Path
::
new
(
"/.dockerenv"
)
.exists
()
||
std
::
path
::
Path
::
new
(
"/run/.containerenv"
)
.exists
();
let
running_within_docker
=
is_running_in_docker
();
let
has_http_access
=
has_http_access
();
let
uses_proxy
=
env
::
var_os
(
"HTTP_PROXY"
)
.is_some
()
||
env
::
var_os
(
"http_proxy"
)
.is_some
()
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
23
−
2
View file @
9859ba63
...
...
@@ -38,6 +38,7 @@ mod util;
pub
use
config
::
CONFIG
;
pub
use
error
::{
Error
,
MapResult
};
pub
use
util
::
is_running_in_docker
;
fn
main
()
{
parse_args
();
...
...
@@ -52,6 +53,7 @@ fn main() {
_
=>
false
,
};
check_data_folder
();
check_rsa_keys
();
check_web_vault
();
...
...
@@ -215,9 +217,28 @@ fn chain_syslog(logger: fern::Dispatch) -> fern::Dispatch {
}
}
fn
create_dir
(
path
:
&
str
,
description
:
&
str
)
{
// Try to create the specified dir, if it doesn't already exist.
let
err_msg
=
format!
(
"Error creating {} directory '{}'"
,
description
,
path
);
create_dir_all
(
path
)
.expect
(
&
err_msg
);
}
fn
create_icon_cache_folder
()
{
// Try to create the icon cache folder, and generate an error if it could not.
create_dir_all
(
&
CONFIG
.icon_cache_folder
())
.expect
(
"Error creating icon cache directory"
);
create_dir
(
&
CONFIG
.icon_cache_folder
(),
"icon cache"
);
}
fn
check_data_folder
()
{
let
data_folder
=
&
CONFIG
.data_folder
();
let
path
=
Path
::
new
(
data_folder
);
if
!
path
.exists
()
{
error!
(
"Data folder '{}' doesn't exist."
,
data_folder
);
if
is_running_in_docker
()
{
error!
(
"Verify that your data volume is mounted at the correct location."
);
}
else
{
error!
(
"Create the data folder and try again."
);
}
exit
(
1
);
}
}
fn
check_rsa_keys
()
{
...
...
This diff is collapsed.
Click to expand it.
src/util.rs
+
9
−
0
View file @
9859ba63
...
...
@@ -358,6 +358,15 @@ pub fn format_naive_datetime_local(dt: &NaiveDateTime, fmt: &str) -> String {
format_datetime_local
(
&
Local
.from_utc_datetime
(
dt
),
fmt
)
}
//
// Deployment environment methods
//
/// Returns true if the program is running in Docker or Podman.
pub
fn
is_running_in_docker
()
->
bool
{
Path
::
new
(
"/.dockerenv"
)
.exists
()
||
Path
::
new
(
"/run/.containerenv"
)
.exists
()
}
//
// Deserialization methods
//
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment