use 2 arguments for owner and repository path
This commit is contained in:
parent
88776d2ec5
commit
9ff3fac39d
12
deploy.sh
12
deploy.sh
@ -10,12 +10,12 @@
|
||||
# Abort deploy on any mistake
|
||||
set -e
|
||||
|
||||
WEB_ROOT=/var/www/pages.abstractnonsen.se/
|
||||
WEB_ROOT=/var/www/wildcard.users.abstractnonsen.se/
|
||||
STORAGE_ROOT=/var/lib/pages/
|
||||
PAGES_USER=pages
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 DEPLOY_SUBDIR"
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 NAMESPACE REPOSITORY"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -24,9 +24,9 @@ if [ "$(whoami)" != "${PAGES_USER}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LINK="${WEB_ROOT}/$1"
|
||||
LINK="${WEB_ROOT}/$1/$2"
|
||||
LINK_DIRECTORY=$(dirname "${LINK}")
|
||||
STORAGE_NEW="${STORAGE_ROOT}/$1/$(date +%s)"
|
||||
STORAGE_NEW="${STORAGE_ROOT}/$1/$2/$(date +%s)"
|
||||
|
||||
# ensure root paths exist
|
||||
mkdir -p "${LINK_DIRECTORY}"
|
||||
@ -53,4 +53,4 @@ else
|
||||
rm -rf "${STORAGE_OLD}"
|
||||
fi
|
||||
|
||||
echo "Successfully deployed to https://pages.abstractnonsen.se/$1"
|
||||
echo "Successfully deployed to https://$1.users.abstractnonsen.se/$2"
|
||||
|
13
setup-key.sh
13
setup-key.sh
@ -12,13 +12,14 @@ DEPLOY_SCRIPT=/home/${PAGES_USER}/deploy.sh
|
||||
mkdir -p "${KEY_DIR}"
|
||||
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 DEPLOY_SUBDIR"
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 OWNER REPOSITORY"
|
||||
fi
|
||||
|
||||
KEYNAME=$1
|
||||
OWNER=$1
|
||||
REPOSITORY=$2
|
||||
|
||||
KEYFILE="${KEY_DIR}/id_${KEYNAME/\//.}"
|
||||
KEYFILE="${KEY_DIR}/id_${OWNER}.${REPOSITORY}"
|
||||
|
||||
if [ -e "${KEYFILE}" ]; then
|
||||
echo "Found existing key in ${KEYFILE}, aborting."
|
||||
@ -31,10 +32,10 @@ mkdir -p "${KEY_DIR}"
|
||||
chmod 700 "${KEY_DIR}"
|
||||
|
||||
# generate key
|
||||
ssh-keygen -t ed25519 -f "${KEYFILE}" -N "" -C "deployment key for ${KEYNAME}" > /dev/null
|
||||
ssh-keygen -t ed25519 -f "${KEYFILE}" -N "" -C "deployment key for ${OWNER}/${REPOSITORY}" > /dev/null
|
||||
|
||||
# add public key
|
||||
echo "command=\"${DEPLOY_SCRIPT} ${KEYNAME}\",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty,no-user-rc,restrict $(cat ${KEYFILE}.pub)" >> "/home/${PAGES_USER}/.ssh/authorized_keys"
|
||||
echo "command=\"${DEPLOY_SCRIPT} ${OWNER} ${REPOSITORY}\",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty,no-user-rc,restrict $(cat ${KEYFILE}.pub)" >> "/home/${PAGES_USER}/.ssh/authorized_keys"
|
||||
|
||||
echo "Generate and configured new key in ${KEYFILE}"
|
||||
echo "Printing private key:"
|
||||
|
Loading…
Reference in New Issue
Block a user