mirror of
https://github.com/IT4Change/gradido.git
synced 2026-04-06 01:25:28 +00:00
Merge pull request #3588 from gradido/update_deployment
fix(workflow): make deployment install script more robust
This commit is contained in:
commit
f2ad3a49f6
@ -24,24 +24,24 @@ packages:
|
|||||||
- expect
|
- expect
|
||||||
package_update: true
|
package_update: true
|
||||||
package_upgrade: true
|
package_upgrade: true
|
||||||
|
write_files:
|
||||||
|
- path: /etc/ssh/sshd_config.d/ssh-hardening.conf
|
||||||
|
content: |
|
||||||
|
PermitRootLogin yes
|
||||||
|
PasswordAuthentication no
|
||||||
|
KbdInteractiveAuthentication no
|
||||||
|
ChallengeResponseAuthentication no
|
||||||
|
MaxAuthTries 3
|
||||||
|
AllowTcpForwarding no
|
||||||
|
X11Forwarding no
|
||||||
|
AllowAgentForwarding no
|
||||||
|
AuthorizedKeysFile .ssh/authorized_keys
|
||||||
|
AllowUsers gradido root
|
||||||
runcmd:
|
runcmd:
|
||||||
- printf "[sshd]\nenabled = true\nbanaction = iptables-multiport" > /etc/fail2ban/jail.local
|
- printf "[sshd]\nenabled = true\nbanaction = iptables-multiport" > /etc/fail2ban/jail.local
|
||||||
- systemctl enable fail2ban
|
- systemctl enable fail2ban
|
||||||
|
|
||||||
- ufw allow OpenSSH
|
- ufw allow OpenSSH
|
||||||
- ufw allow http
|
- ufw allow http
|
||||||
- ufw allow https
|
- ufw allow https
|
||||||
- ufw enable
|
- ufw enable
|
||||||
|
|
||||||
- sed -i -e '/^\(#\|\)PasswordAuthentication/s/^.*$/PasswordAuthentication no/' /etc/ssh/sshd_config
|
|
||||||
- sed -i -e '/^\(#\|\)KbdInteractiveAuthentication/s/^.*$/KbdInteractiveAuthentication no/' /etc/ssh/sshd_config
|
|
||||||
- sed -i -e '/^\(#\|\)ChallengeResponseAuthentication/s/^.*$/ChallengeResponseAuthentication no/' /etc/ssh/sshd_config
|
|
||||||
- sed -i -e '/^\(#\|\)MaxAuthTries/s/^.*$/MaxAuthTries 3/' /etc/ssh/sshd_config
|
|
||||||
- sed -i -e '/^\(#\|\)AllowTcpForwarding/s/^.*$/AllowTcpForwarding no/' /etc/ssh/sshd_config
|
|
||||||
- sed -i -e '/^\(#\|\)X11Forwarding/s/^.*$/X11Forwarding no/' /etc/ssh/sshd_config
|
|
||||||
- sed -i -e '/^\(#\|\)AllowAgentForwarding/s/^.*$/AllowAgentForwarding no/' /etc/ssh/sshd_config
|
|
||||||
- sed -i -e '/^\(#\|\)AuthorizedKeysFile/s/^.*$/AuthorizedKeysFile .ssh\/authorized_keys/' /etc/ssh/sshd_config
|
|
||||||
- sed -i '$a AllowUsers gradido root' /etc/ssh/sshd_config
|
|
||||||
|
|
||||||
- reboot
|
- reboot
|
||||||
@ -124,17 +124,27 @@ sudo systemctl daemon-reload
|
|||||||
# setup https with certbot
|
# setup https with certbot
|
||||||
certbot certonly --nginx --non-interactive --agree-tos --domains $COMMUNITY_HOST --email $COMMUNITY_SUPPORT_MAIL
|
certbot certonly --nginx --non-interactive --agree-tos --domains $COMMUNITY_HOST --email $COMMUNITY_SUPPORT_MAIL
|
||||||
|
|
||||||
# Install node 18
|
# run as gradido user (until EOF)
|
||||||
sudo -u gradido bash -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash'
|
sudo -u gradido bash <<'EOF'
|
||||||
# Close and reopen your terminal to start using nvm or run the following to use it now:
|
export NVM_DIR="/home/gradido/.nvm"
|
||||||
sudo -u gradido bash -c 'export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
|
NODE_VERSION="v18.20.7"
|
||||||
sudo -u gradido bash -c '. $HOME/.nvm/nvm.sh && nvm install v18.20.7' # first installed version will be set to default automatic
|
export NVM_DIR
|
||||||
|
# Install nvm if it doesn't exist
|
||||||
|
if [ ! -d "$NVM_DIR" ]; then
|
||||||
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
|
||||||
|
fi
|
||||||
|
# Load nvm
|
||||||
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||||
|
|
||||||
# Install yarn
|
# Install Node if not already installed
|
||||||
sudo -u gradido bash -c '. $HOME/.nvm/nvm.sh && npm i -g yarn'
|
if ! nvm ls $NODE_VERSION >/dev/null 2>&1; then
|
||||||
|
nvm install $NODE_VERSION
|
||||||
# Install pm2
|
fi
|
||||||
sudo -u gradido bash -c '. $HOME/.nvm/nvm.sh && npm i -g pm2 && pm2 startup'
|
# Install yarn and pm2
|
||||||
|
npm i -g yarn pm2
|
||||||
|
# start pm2
|
||||||
|
pm2 startup
|
||||||
|
EOF
|
||||||
|
|
||||||
# Install logrotate
|
# Install logrotate
|
||||||
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $SCRIPT_PATH/logrotate/gradido.conf.template > $SCRIPT_PATH/logrotate/gradido.conf
|
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $SCRIPT_PATH/logrotate/gradido.conf.template > $SCRIPT_PATH/logrotate/gradido.conf
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user