Upload files to "/"
This commit is contained in:
commit
5c16fa6ac5
58
corn-continious-deployment.sh
Normal file
58
corn-continious-deployment.sh
Normal file
@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Simple Continious Deployment script
|
||||
# - Compares hashes of the local and remote main git branches
|
||||
# - Pulls changes if needed
|
||||
# - If changes was pulled, builds and deploys them
|
||||
|
||||
# TODO
|
||||
# - Configuration to use with a specific git branch
|
||||
# - Replace hard coded variables with script arguments
|
||||
|
||||
# Crontab entry:
|
||||
# * * * * * bash /usr/local/bin/static-site-continious-deployment.sh >> /var/log/deploy-cuqmbr-xyz.log 2>&1
|
||||
|
||||
set -Eeuo pipefail
|
||||
trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
|
||||
|
||||
|
||||
GIT_REPO_PATH="/opt/cuqmbr.xyz.git"
|
||||
DEPLOY_PATH="/var/www/cuqmbr.xyz"
|
||||
|
||||
|
||||
build() {
|
||||
touch cron-lock
|
||||
|
||||
# Replace with your build script
|
||||
hugo
|
||||
|
||||
rm cron-lock
|
||||
}
|
||||
|
||||
deploy() {
|
||||
# Replace with your deployment strategy
|
||||
ln -snfv ${GIT_REPO_PATH}/public ${DEPLOY_PATH}
|
||||
}
|
||||
|
||||
if [ ! -d ${GIT_REPO_PATH} ]; then
|
||||
git clone --recurse-submodules 'https://gitea.cuqmbr.xyz/cuqmbr/cuqmbr.xyz.git' ${GIT_REPO_PATH}
|
||||
build
|
||||
deploy
|
||||
exit 0
|
||||
fi
|
||||
|
||||
start_dir=$(pwd)
|
||||
cd ${GIT_REPO_PATH}
|
||||
|
||||
git remote update
|
||||
LOCAL_COMMIT=$(git rev-parse @)
|
||||
REMOTE_COMMIT=$(git rev-parse @{u})
|
||||
|
||||
if [ "$LOCAL_COMMIT" != "$REMOTE_COMMIT" ]; then
|
||||
git reset --hard 'origin/main'
|
||||
rm -Rf public
|
||||
build
|
||||
deploy
|
||||
fi
|
||||
|
||||
cd "${start_dir}"
|
30
init-debian-server.sh
Normal file
30
init-debian-server.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Script for initial setup of Debian(-based) distributions
|
||||
|
||||
# Must be run with root privileges
|
||||
# Before running the script, copy ssh public key file to root user with ssh-copy-id
|
||||
|
||||
set -Eeuo pipefail
|
||||
trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
|
||||
|
||||
|
||||
USERNAME="cuqmbr"
|
||||
|
||||
|
||||
apt-get update && apt-get upgrade -y
|
||||
apt-get install doas -y
|
||||
|
||||
useradd --create-home --shell /bin/bash "${USERNAME}"
|
||||
passwd "${USERNAME}"
|
||||
|
||||
echo 'permit persist cuqmbr as root' > /etc/doas.conf
|
||||
|
||||
mkdir "/home/${USERNAME}/.ssh"
|
||||
cp .ssh/authorized_keys "/home/${USERNAME}/.ssh/"
|
||||
echo 'alias sudo=doas' > "/home/${USERNAME}/.bash_aliases"
|
||||
chown -R "{$USERNAME}:${USERNAME}" "/home/${USERNAME}/"
|
||||
|
||||
sed -i -e 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
|
||||
sed -i -e 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
|
||||
systemctl reload sshd
|
Loading…
Reference in New Issue
Block a user