~jonn/cdn

2b64f86510c87782682eb60a114ad3215c3dd132 — Jonn 3 years ago b24c1c6
Problem: cdup didn't work without -r, warnings

Solution:

 - Fix cdup to upload files in a flat way
 - Fix shellcheck warnings

Currently we're doing the following:

 - Make `cdn` directory in the project
 - `cdup cdn` when needed
2 files changed, 6 insertions(+), 4 deletions(-)

M cdup
M mkBucket
M cdup => cdup +2 -2
@@ 35,11 35,11 @@ if [ -n "$3" ]; then
fi

# Build CDN rsync-compatible FQN
_cdn="cdn@${_bucket}.${_host}:cdn/${_bucket}"
_cdn="cdn@${_bucket}.${_host}:/cdn/${_bucket}"

# We don't care about the port, since CDN hosts should be configured in
# .ssh/config
#
# We don't use -a because we want to change ownership to `cdn` user and make
# files world-readable
rsync -Pve 'ssh' "$_localPath" "${_cdn}/${_localPath}"
\ No newline at end of file
rsync -Prve 'ssh' "$_localPath" "${_cdn}"

M mkBucket => mkBucket +4 -2
@@ 72,7 72,8 @@ if [ -z "$(dig +short "${_fqdn}")" ]; then
fi

mkdir -p "/cdn/${_bucket}"
cd "/cdn/${_bucket}"
echo "Trying to 'cd /cdn/${_bucket}'"
cd "/cdn/${_bucket}" || exit 111
cat > "/cdn/${_bucket}/package.json" <<EOL
{
  "name": "${_bucket}-cdn",


@@ 89,7 90,8 @@ EOL
chown -R cdn "/cdn/"
chown -R cdn "/cdn/${_bucket}"
su cdn -c 'npm i --save-dev serve'
cd -
echo "Trying to 'cd -'"
cd - || exit 111

cat > "/etc/nginx/sites-enabled/${_fqdn}" <<EOL
server {