mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
improved installscript alot
- proper order - templates for all configs to fill in automatically
This commit is contained in:
parent
4079e6818f
commit
8fcc3b31ad
4
admin/.env.template
Normal file
4
admin/.env.template
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
GRAPHQL_URI=${GRAPHQL_URI}
|
||||||
|
WALLET_AUTH_URL=${WALLET_AUTH_URL}
|
||||||
|
WALLET_URL=${WALLET_URL}
|
||||||
|
DEBUG_DISABLE_AUTH=false
|
||||||
33
backend/.env .template
Normal file
33
backend/.env .template
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
PORT=4000
|
||||||
|
JWT_SECRET=${JWT_SECRET}
|
||||||
|
JWT_EXPIRES_IN=10m
|
||||||
|
GRAPHIQL=false
|
||||||
|
GDT_API_URL=https://gdt.gradido.net
|
||||||
|
DB_HOST=localhost
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_USER=${DB_USER}
|
||||||
|
DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
DB_DATABASE=gradido_community
|
||||||
|
|
||||||
|
EMAIL=${EMAIL}
|
||||||
|
EMAIL_USERNAME=${EMAIL_USERNAME}
|
||||||
|
EMAIL_SENDER=${EMAIL_SENDER}
|
||||||
|
EMAIL_PASSWORD=${EMAIL_PASSWORD}
|
||||||
|
EMAIL_SMTP_URL=§{EMAIL_SMTP_URL}
|
||||||
|
EMAIL_SMTP_PORT=587
|
||||||
|
#RESEND_TIME=1 minute, 60 => 1hour, 1440 (60 minutes * 24 hours) => 24 hours
|
||||||
|
RESEND_TIME=10
|
||||||
|
|
||||||
|
EMAIL_LINK_VERIFICATION=${EMAIL_LINK_VERIFICATION}
|
||||||
|
|
||||||
|
#KLICKTIPP_USER=
|
||||||
|
#KLICKTIPP_PASSWORD=
|
||||||
|
#KLICKTIPP_APIKEY_DE=
|
||||||
|
#KLICKTIPP_APIKEY_EN=
|
||||||
|
#KLICKTIPP=true
|
||||||
|
COMMUNITY_NAME=
|
||||||
|
COMMUNITY_URL=
|
||||||
|
COMMUNITY_REGISTER_URL=
|
||||||
|
COMMUNITY_DESCRIPTION=
|
||||||
|
|
||||||
|
WEBHOOK_ELOPAGE_SECRET=${WEBHOOK_ELOPAGE_SECRET}
|
||||||
8
database/.env.template
Normal file
8
database/.env.template
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
DB_HOST=localhost
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_USER=${DB_USER}
|
||||||
|
DB_PASSWORD=${DB_PASSWORD}
|
||||||
|
DB_DATABASE=gradido_community
|
||||||
|
MIGRATIONS_TABLE=migrations
|
||||||
|
|
||||||
|
TYPEORM_SEEDING_FACTORIES=src/factories/**/*{.ts,.js}
|
||||||
@ -3,15 +3,26 @@
|
|||||||
# This install script requires the minimum requirements already installed.
|
# This install script requires the minimum requirements already installed.
|
||||||
# How to do this is described in detail in [setup.md](./setup.md)
|
# How to do this is described in detail in [setup.md](./setup.md)
|
||||||
|
|
||||||
|
# Find current directory & configure paths
|
||||||
|
set -o allexport
|
||||||
|
SCRIPT_PATH=$(realpath $0)
|
||||||
|
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
|
||||||
|
PROJECT_ROOT=$SCRIPT_DIR/../..
|
||||||
|
set +o allexport
|
||||||
|
|
||||||
# Load .env or .env.dist if not present
|
# Load .env or .env.dist if not present
|
||||||
set -o allexport
|
set -o allexport
|
||||||
if [ -f ".env" ]; then
|
#TODO
|
||||||
source .env
|
if [ -f "$SCRIPT_DIR/.env" ]; then
|
||||||
|
source $SCRIPT_DIR/.env
|
||||||
else
|
else
|
||||||
source .env.dist
|
source $SCRIPT_DIR/.env.dist
|
||||||
fi
|
fi
|
||||||
set +o allexport
|
set +o allexport
|
||||||
|
|
||||||
|
# Configure git
|
||||||
|
git config pull.ff only
|
||||||
|
|
||||||
# Install mariadb
|
# Install mariadb
|
||||||
sudo apt-get install -y mariadb-server
|
sudo apt-get install -y mariadb-server
|
||||||
sudo mysql_secure_installation
|
sudo mysql_secure_installation
|
||||||
@ -23,57 +34,24 @@ sudo mysql_secure_installation
|
|||||||
# Remove test database and access to it? [Y/n] Y
|
# Remove test database and access to it? [Y/n] Y
|
||||||
# Reload privilege tables now? [Y/n] Y
|
# Reload privilege tables now? [Y/n] Y
|
||||||
|
|
||||||
# create db user
|
|
||||||
DB_USER=gradido
|
|
||||||
DB_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo);
|
|
||||||
# create table
|
|
||||||
#create database gradido_community
|
|
||||||
# DEFAULT CHARACTER SET utf8mb4
|
|
||||||
# DEFAULT COLLATE utf8mb4_unicode_ci;
|
|
||||||
# GRANT ALL PRIVILEGES ON gradido_community.* TO '$DB_USER'@'localhost';
|
|
||||||
sudo mysql <<EOFMYSQL
|
|
||||||
CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASSWD';
|
|
||||||
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'localhost';
|
|
||||||
FLUSH PRIVILEGES;
|
|
||||||
EOFMYSQL
|
|
||||||
# TODO generate .env
|
|
||||||
echo $DB_PASSWORD
|
|
||||||
|
|
||||||
#TODO go to database
|
|
||||||
#TODO generate this
|
|
||||||
#TODO database setup
|
|
||||||
cp .env.dist .env
|
|
||||||
|
|
||||||
#TODO go to backend
|
|
||||||
#TODO generate this
|
|
||||||
#TODO database setup
|
|
||||||
#TODOchange jwt secret
|
|
||||||
#TODO change email releated stuff
|
|
||||||
cp .env.dist .env
|
|
||||||
|
|
||||||
#TODO go to frontend
|
|
||||||
#TODO generate this
|
|
||||||
#TODO backend url
|
|
||||||
#TODO admin url
|
|
||||||
cp .env.dist .env
|
|
||||||
|
|
||||||
#TODO go to admin
|
|
||||||
#TODO generate this
|
|
||||||
#TODO change graphqlurl
|
|
||||||
#TODO change wallet url
|
|
||||||
|
|
||||||
cp .env.dist .env
|
|
||||||
|
|
||||||
#TODO import old database
|
|
||||||
|
|
||||||
# Install nginx
|
# Install nginx
|
||||||
sudo apt-get install -y nginx
|
sudo apt-get install -y nginx
|
||||||
sudo rm /etc/nginx/sites-enabled/default
|
sudo rm /etc/nginx/sites-enabled/default
|
||||||
sudo ln -s /home/gradido/gradido/deployment/bare_metal/nginx/sites-available/gradido.conf /etc/nginx/sites-available
|
# sudo ln -s /home/gradido/gradido/deployment/bare_metal/nginx/sites-available/gradido.conf /etc/nginx/sites-available
|
||||||
sudo ln -s /etc/nginx/sites-available/gradido.conf /etc/nginx/sites-enabled
|
# sudo ln -s /etc/nginx/sites-available/gradido.conf /etc/nginx/sites-enabled
|
||||||
sudo ln -s /home/gradido/gradido/deployment/bare_metal/nginx/sites-available/update-page.conf /etc/nginx/sites-available
|
# sudo ln -s /home/gradido/gradido/deployment/bare_metal/nginx/sites-available/update-page.conf /etc/nginx/sites-available
|
||||||
cd /etc/nginx
|
sudo ln -s /home/gradido/gradido/deployment/bare_metal/nginx/common /etc/nginx/
|
||||||
sudo ln -s /home/gradido/gradido/deployment/bare_metal/nginx/common common
|
|
||||||
|
# Allow nginx configuration and restart for gradido
|
||||||
|
#TODO generate file
|
||||||
|
sudo nano /etc/sudoers.d/gradido
|
||||||
|
> gradido ALL=(ALL) NOPASSWD: /etc/init.d/nginx start,/etc/init.d/nginx stop,/etc/init.d/nginx restart
|
||||||
|
sudo chmod a+rw /etc/nginx/sites-enabled
|
||||||
|
|
||||||
|
# Install node 16.x
|
||||||
|
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
|
||||||
|
sudo apt-get install -y nodejs
|
||||||
|
sudo apt-get install -y build-essential
|
||||||
|
|
||||||
# Install yarn
|
# Install yarn
|
||||||
sudo apt-get install -y curl
|
sudo apt-get install -y curl
|
||||||
@ -83,32 +61,22 @@ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/source
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y yarn
|
sudo apt-get install -y yarn
|
||||||
|
|
||||||
# Install node 16.x
|
|
||||||
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
|
|
||||||
sudo apt-get install -y nodejs
|
|
||||||
sudo apt-get install -y build-essential
|
|
||||||
|
|
||||||
# Install pm2
|
# Install pm2
|
||||||
sudo yarn global add pm2
|
sudo yarn global add pm2
|
||||||
|
|
||||||
# Install certbot
|
# Install certbot
|
||||||
|
sudo /etc/init.d/nginx stop
|
||||||
sudo apt-get install -y certbot
|
sudo apt-get install -y certbot
|
||||||
sudo apt-get install -y python3-certbot-nginx
|
sudo certbot certonly
|
||||||
sudo certbot --certonly
|
|
||||||
> Enter email address (used for urgent renewal and security notices) > support@gradido.net
|
> Enter email address (used for urgent renewal and security notices) > support@gradido.net
|
||||||
> Please read the Terms of Service at > Y
|
> Please read the Terms of Service at > Y
|
||||||
> Would you be willing, once your first certificate is successfully issued, to > N
|
> Would you be willing, once your first certificate is successfully issued, to > N
|
||||||
> No names were found in your configuration files. Please enter in your domain > stage1.gradido.net
|
> No names were found in your configuration files. Please enter in your domain > stage1.gradido.net
|
||||||
|
sudo /etc/init.d/nginx start
|
||||||
|
|
||||||
git config pull.ff only
|
# Webhooks (optional) (for development)
|
||||||
|
|
||||||
# Allow nginx configuration and restart for gradido
|
|
||||||
sudo nano /etc/sudoers.d/gradido
|
|
||||||
> gradido ALL=(ALL) NOPASSWD: /etc/init.d/nginx start,/etc/init.d/nginx stop,/etc/init.d/nginx restart
|
|
||||||
sudo chmod a+rw /etc/nginx/sites-enabled
|
|
||||||
|
|
||||||
# Webhooks (optional)
|
|
||||||
sudo apt install webhook
|
sudo apt install webhook
|
||||||
|
# TODO generate
|
||||||
nano ~/hooks.json
|
nano ~/hooks.json
|
||||||
```
|
```
|
||||||
[
|
[
|
||||||
@ -118,7 +86,7 @@ nano ~/hooks.json
|
|||||||
"pass-arguments-to-command": [
|
"pass-arguments-to-command": [
|
||||||
{
|
{
|
||||||
"source": "string",
|
"source": "string",
|
||||||
"name": "new_deployment"
|
"name": "master"
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"command-working-directory": "/home/gradido/gradido/deployment/bare_metal",
|
"command-working-directory": "/home/gradido/gradido/deployment/bare_metal",
|
||||||
@ -137,7 +105,7 @@ nano ~/hooks.json
|
|||||||
{
|
{
|
||||||
"match": {
|
"match": {
|
||||||
"type": "value",
|
"type": "value",
|
||||||
"value": "refs/heads/new_deployment",
|
"value": "refs/heads/master",
|
||||||
"parameter": {
|
"parameter": {
|
||||||
"source": "payload",
|
"source": "payload",
|
||||||
"name": "ref"
|
"name": "ref"
|
||||||
@ -152,4 +120,33 @@ nano ~/hooks.json
|
|||||||
|
|
||||||
webhook -hooks ~/hooks.json &
|
webhook -hooks ~/hooks.json &
|
||||||
# or for debugging
|
# or for debugging
|
||||||
webhook -hooks ~/hooks.json -verbose
|
webhook -hooks ~/hooks.json -verbose
|
||||||
|
|
||||||
|
# create db user
|
||||||
|
DB_USER=gradido
|
||||||
|
DB_PASSWORD=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo);
|
||||||
|
# create table
|
||||||
|
#create database gradido_community
|
||||||
|
# DEFAULT CHARACTER SET utf8mb4
|
||||||
|
# DEFAULT COLLATE utf8mb4_unicode_ci;
|
||||||
|
# GRANT ALL PRIVILEGES ON gradido_community.* TO '$DB_USER'@'localhost';
|
||||||
|
sudo mysql <<EOFMYSQL
|
||||||
|
CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASSWORD';
|
||||||
|
GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'localhost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
EOFMYSQL
|
||||||
|
|
||||||
|
# Configure database
|
||||||
|
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/database/.env.template > $PROJECT_ROOT/database/.env
|
||||||
|
|
||||||
|
# Configure backend
|
||||||
|
JWT_SECRET=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo);
|
||||||
|
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/backend/.env.template > $PROJECT_ROOT/backend/.env
|
||||||
|
|
||||||
|
# Configure frontend
|
||||||
|
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/frontend/.env.template > $PROJECT_ROOT/frontend/.env
|
||||||
|
|
||||||
|
# Configure admin
|
||||||
|
envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < $PROJECT_ROOT/admin/.env.template > $PROJECT_ROOT/admin/.env
|
||||||
|
|
||||||
|
#TODO import old database
|
||||||
3
frontend/.env.template
Normal file
3
frontend/.env.template
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
GRAPHQL_URI=${GRAPHQL_URI}
|
||||||
|
DEFAULT_PUBLISHER_ID=2896
|
||||||
|
ADMIN_AUTH_URL=${ADMIN_AUTH_URL}
|
||||||
Loading…
x
Reference in New Issue
Block a user