forked from thijsvanloef/palworld-server-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request thijsvanloef#334 from Dashboy1998/File-checks-for-…
…config-generation File checks for config generation
- Loading branch information
Showing
3 changed files
with
90 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
# This file contains functions which can be used in multiple scripts | ||
|
||
# Checks if a given path is a directory | ||
# Returns 0 if the path is a directory | ||
# Returns 1 if the path is not a directory or does not exists and produces an output message | ||
dirExists() { | ||
local path="$1" | ||
local return_val=0 | ||
if ! [ -d "${path}" ]; then | ||
echo "${path} does not exist." | ||
return_val=1 | ||
fi | ||
return "$return_val" | ||
} | ||
|
||
# Checks if a given path is a regular file | ||
# Returns 0 if the path is a regular file | ||
# Returns 1 if the path is not a regular file or does not exists and produces an output message | ||
fileExists() { | ||
local path="$1" | ||
local return_val=0 | ||
if ! [ -f "${path}" ]; then | ||
echo "${path} does not exist." | ||
return_val=1 | ||
fi | ||
return "$return_val" | ||
} | ||
|
||
# Checks if a given path exists and is readable | ||
# Returns 0 if the path exists and is readable | ||
# Returns 1 if the path is not readable or does not exists and produces an output message | ||
isReadable() { | ||
local path="$1" | ||
local return_val=0 | ||
if ! [ -e "${path}" ]; then | ||
echo "${path} is not readable." | ||
return_val=1 | ||
fi | ||
return "$return_val" | ||
} | ||
|
||
# Checks if a given path is writable | ||
# Returns 0 if the path is writable | ||
# Returns 1 if the path is not writable or does not exists and produces an output message | ||
isWritable() { | ||
local path="$1" | ||
local return_val=0 | ||
if ! [ -w "${path}" ]; then | ||
echo "${path} is not writable." | ||
return_val=1 | ||
fi | ||
return "$return_val" | ||
} | ||
|
||
# Checks if a given path is executable | ||
# Returns 0 if the path is executable | ||
# Returns 1 if the path is not executable or does not exists and produces an output message | ||
isExecutable() { | ||
local path="$1" | ||
local return_val=0 | ||
if ! [ -x "${path}" ]; then | ||
echo "${path} is not executable." | ||
return_val=1 | ||
fi | ||
return "$return_val" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters