deploy: use /bin/sh, support freebsd

This commit is contained in:
Evgeny Zinoviev 2024-10-22 20:12:42 +00:00
parent 44982d22c9
commit 7731cfb161
4 changed files with 15 additions and 15 deletions

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -e set -e
@ -34,7 +34,7 @@ EOF
input_args() { input_args() {
[ -z "$1" ] && usage [ -z "$1" ] && usage
while [[ $# -gt 0 ]]; do while [ $# -gt 0 ]; do
case $1 in case $1 in
-o) -o)
OUTDIR="$2" OUTDIR="$2"
@ -69,6 +69,6 @@ check_args() {
mkdir "$OUTDIR" mkdir "$OUTDIR"
else else
# warning "$OUTDIR already exists, erasing it" # warning "$OUTDIR already exists, erasing it"
rm "$OUTDIR"/* rm "$OUTDIR"/* || true
fi fi
} }

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
PROGNAME="$0" PROGNAME="$0"
DIR="$( cd "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && pwd )" DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
ROOT="$(realpath "$DIR/../")" ROOT="$(realpath "$DIR/../")"
CLEANCSS="$ROOT"/node_modules/clean-css-cli/bin/cleancss CLEANCSS="$ROOT"/node_modules/clean-css-cli/bin/cleancss

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/sh
PROGNAME="$0" PROGNAME="$0"
DIR="$( cd "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && pwd )" DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
. $DIR/build_common.sh . $DIR/build_common.sh

View File

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
die() { die() {
>&2 echo "error: $@" >&2 echo "error: $@"
@ -7,18 +7,18 @@ die() {
set -e set -e
DIR="$( cd "$( dirname "$(readlink -f "${BASH_SOURCE[0]}")" )" && pwd )" DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
DEV_DIR="$(realpath "$DIR/../")" DEV_DIR="$(realpath "$DIR/../")"
STAGING_DIR="$HOME/staging" STAGING_DIR="$HOME/staging"
PROD_DIR="$HOME/prod" PROD_DIR="$HOME/www"
PHP=/usr/bin/php8.1 PHP="$(which php)"
REPO_URI=$(cat "$DEV_DIR/config.yaml" | grep ^git_repo | head -1 | awk '{print $2}') REPO_URI=$(cat "$DEV_DIR/config.yaml" | grep ^git_repo | head -1 | awk '{print $2}')
git push origin master git push origin master
[ -d "$STAGING_DIR" ] || mkdir "$STAGING_DIR" [ -d "$STAGING_DIR" ] || mkdir "$STAGING_DIR"
pushd "$STAGING_DIR" cd "$STAGING_DIR"
if [ ! -d .git ]; then if [ ! -d .git ]; then
git init git init
@ -30,7 +30,7 @@ fi
git reset --hard git reset --hard
git pull origin master git pull origin master
composer8.1 install --no-dev --optimize-autoloader --ignore-platform-reqs composer install --no-dev --optimize-autoloader --ignore-platform-reqs
if [ ! -d node_modules ]; then if [ ! -d node_modules ]; then
npm i npm i
@ -42,7 +42,7 @@ cp "$DEV_DIR/config.yaml" .
"$DIR"/build_css.sh -i "$DEV_DIR/htdocs/scss" -o "$STAGING_DIR/htdocs/dist-css" || die "build_css failed" "$DIR"/build_css.sh -i "$DEV_DIR/htdocs/scss" -o "$STAGING_DIR/htdocs/dist-css" || die "build_css failed"
$PHP "$DIR"/gen_static_config.php -i "$STAGING_DIR/htdocs" > "$STAGING_DIR/config-static.php" || die "gen_static_config failed" $PHP "$DIR"/gen_static_config.php -i "$STAGING_DIR/htdocs" > "$STAGING_DIR/config-static.php" || die "gen_static_config failed"
popd cd "$DIR"
# copy staging to prod # copy staging to prod
rsync -a --delete --delete-excluded --info=progress2 "$STAGING_DIR/" "$PROD_DIR/" \ rsync -a --delete --delete-excluded --info=progress2 "$STAGING_DIR/" "$PROD_DIR/" \
@ -55,4 +55,4 @@ rsync -a --delete --delete-excluded --info=progress2 "$STAGING_DIR/" "$PROD_DIR/
--exclude='/htdocs/sass.php' \ --exclude='/htdocs/sass.php' \
--exclude='/htdocs/js.php' \ --exclude='/htdocs/js.php' \
--exclude='*.sh' \ --exclude='*.sh' \
--exclude='*.sql' --exclude='*.sql'