From e60142e16ffa327ccab917eae726a82a654a3c03 Mon Sep 17 00:00:00 2001 From: cubic Date: Mon, 5 Jun 2023 15:55:40 +0800 Subject: [PATCH] feat(docker): add init scripts --- misc/initailize_container.sh | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 misc/initailize_container.sh diff --git a/misc/initailize_container.sh b/misc/initailize_container.sh new file mode 100644 index 0000000..53d1313 --- /dev/null +++ b/misc/initailize_container.sh @@ -0,0 +1,43 @@ +#!/bin/bash +echo '> Start post initialization...' + +cp ../config.template.yaml ../config.yaml +cp ../env.template.yaml ../env.yaml +chmod 0777 ../config.yaml ../env.yaml +chmod -R 0777 ../git-storage + +chown -R git:git ../application/logs +chown -R git:git ../file-storage +chown -R git:git ../misc + +TARGET_CRONJOB=`crontab -u git -l 2>/dev/null | grep 'codefever_schedule.sh' | wc -l` +if [ $TARGET_CRONJOB -eq 0 ]; then + crontab -u git -l 2>/dev/null > /tmp/cronjob.temp + echo "* * * * * sh /data/www/codefever-community/application/backend/codefever_schedule.sh" >> /tmp/cronjob.temp + crontab -u git /tmp/cronjob.temp + rm -f /tmp/cronjob.temp +fi + +echo 'Generateing public key for ssh: (Just Press Enter Key!)' +sudo -u git ssh-keygen -f /home/git/.ssh/id_rsa +service sshd restart + +# start services +service codefever start +service php-fpm start +service nginx start +service crond start +service sendmail start + +# enable all services +chkconfig mariadb on +chkconfig sendmail on +chkconfig nginx on +chkconfig php-fpm on +chkconfig codefever on +chkconfig crond on + +# set mysql root password +echo 'Start Database Initialization...' +./misc/create_db.sh +