Switch to double bracket tests, reduce redundancy
This commit is contained in:
@@ -16,41 +16,25 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
function fail_with_message {
|
||||||
|
echo "$1"
|
||||||
|
echo "Exiting container."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
# Check mandatory Seafile configuration have been properly set.
|
# Check mandatory Seafile configuration have been properly set.
|
||||||
if [ -z $SEAF_SERVER_URL ]; then
|
[[ -z "$SEAF_SERVER_URL" ]] && fail_with_message "The \$SEAF_SERVER_URL is not defined."
|
||||||
echo "The \$SEAF_SERVER_URL is not defined. Stopping container..."
|
[[ -z "$SEAF_USERNAME" ]] && fail_with_message "The \$SEAF_USERNAME is not defined."
|
||||||
exit 1
|
[[ -z "$SEAF_PASSWORD" ]] && fail_with_message "The \$SEAF_PASSWORD is not defined."
|
||||||
fi
|
[[ -z "$SEAF_LIBRARY_UUID" ]] && fail_with_message "The \$SEAF_LIBRARY_UUID is not defined."
|
||||||
if [ -z $SEAF_USERNAME ]; then
|
[[ -n "$SEAF_UPLOAD_LIMIT" && $SEAF_UPLOAD_LIMIT =~ ^[0-9]+$ && "$SEAF_UPLOAD_LIMIT" -gt 0 ]] && \
|
||||||
echo "The \$SEAF_USERNAME is not defined. Stopping container..."
|
fail_with_message "The \$SEAF_UPLOAD_LIMIT is not an integer greater than 0."
|
||||||
exit 1
|
[[ -n "$SEAF_DOWNLOAD_LIMIT" && $SEAF_DOWNLOAD_LIMIT =~ ^[0-9]+$ && "$SEAF_DOWNLOAD_LIMIT" -gt 0 ]] && \
|
||||||
fi
|
fail_with_message "The \$SEAF_DOWNLOAD_LIMIT is not an integer greater than 0."
|
||||||
if [ -z $SEAF_PASSWORD ]; then
|
|
||||||
echo "The \$SEAF_PASSWORD is not defined. Stopping container..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ -z $SEAF_LIBRARY_UUID ]; then
|
|
||||||
echo "The \$SEAF_LIBRARY_UUID is not defined. Stopping container..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ -n "$SEAF_UPLOAD_LIMIT"
|
|
||||||
&& $SEAF_UPLOAD_LIMIT =~ ^[0-9]+$
|
|
||||||
&& "$SEAF_UPLOAD_LIMIT" -gt 0 ]]; then
|
|
||||||
echo "The \$SEAF_UPLOAD_LIMIT is not an integer greater than 0. Stopping container..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ -n "$SEAF_DOWNLOAD_LIMIT"
|
|
||||||
&& $SEAF_DOWNLOAD_LIMIT =~ ^[0-9]+$
|
|
||||||
&& "$SEAF_DOWNLOAD_LIMIT" -gt 0 ]]; then
|
|
||||||
echo "The \$SEAF_DOWNLOAD_LIMIT is not an integer greater than 0. Stopping container..."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Update the user ID, if the $UID changed.
|
# Update the user ID, if the $UID changed.
|
||||||
if [ "$UID" != "1000" ]; then
|
# TODO: What if the $UID already exists ?
|
||||||
usermod -u $UID $UNAME
|
[[ "$UID" != "1000" ]] && usermod -u $UID $UNAME
|
||||||
# What if the $UID already exists ?
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change the group, if the $GID changed.
|
# Change the group, if the $GID changed.
|
||||||
if [ "$GID" != "1000" ]; then
|
if [ "$GID" != "1000" ]; then
|
||||||
@@ -73,11 +57,10 @@ su - $UNAME << EO
|
|||||||
export SEAF_USERNAME=$SEAF_USERNAME
|
export SEAF_USERNAME=$SEAF_USERNAME
|
||||||
export SEAF_PASSWORD=$SEAF_PASSWORD
|
export SEAF_PASSWORD=$SEAF_PASSWORD
|
||||||
export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID
|
export SEAF_LIBRARY_UUID=$SEAF_LIBRARY_UUID
|
||||||
export SEAF_SKIP_SSL_CERT=$SEAF_SKIP_SSL_CERT
|
[[ "$SEAF_SKIP_SSL_CERT" ]] && export SEAF_SKIP_SSL_CERT=$SEAF_SKIP_SSL_CERT
|
||||||
test -n "$SEAF_UPLOAD_LIMIT" && export SEAF_UPLOAD_LIMIT=$SEAF_UPLOAD_LIMIT
|
[[ "$SEAF_UPLOAD_LIMIT" ]] && export SEAF_UPLOAD_LIMIT=$SEAF_UPLOAD_LIMIT
|
||||||
test -n "$SEAF_DOWNLOAD_LIMIT" && export SEAF_DOWNLOAD_LIMIT=$SEAF_DOWNLOAD_LIMIT
|
[[ "$SEAF_DOWNLOAD_LIMIT" ]] && export SEAF_DOWNLOAD_LIMIT=$SEAF_DOWNLOAD_LIMIT
|
||||||
test -n "$SEAF_2FA_SECRET" && export SEAF_2FA_SECRET=$SEAF_2FA_SECRET
|
[[ "$SEAF_2FA_SECRET" ]] && export SEAF_2FA_SECRET=$SEAF_2FA_SECRET
|
||||||
test -n "$SEAF_LIBRARY_PASSWORD" && export SEAF_LIBRARY_PASSWORD=$SEAF_LIBRARY_PASSWORD
|
[[ "$SEAF_LIBRARY_PASSWORD" ]] && export SEAF_LIBRARY_PASSWORD=$SEAF_LIBRARY_PASSWORD
|
||||||
export UNAME=$UNAME
|
|
||||||
/bin/bash /home/seafuser/entrypoint.sh
|
/bin/bash /home/seafuser/entrypoint.sh
|
||||||
EO
|
EO
|
||||||
|
|||||||
Reference in New Issue
Block a user