mirror of
https://github.com/YunoHost-Apps/snweb_ynh.git
synced 2024-09-03 20:26:22 +02:00
Fix Installation
Autor: Fabian Wilkens <wilkens.fabian+github.com>
This commit is contained in:
parent
c63e663532
commit
cd1235a55a
5 changed files with 36 additions and 27 deletions
|
@ -1,8 +1,9 @@
|
||||||
|
|
||||||
# Rails Settings
|
# Rails Settings
|
||||||
EXPOSED_PORT=__EXPOSED_PORT__
|
|
||||||
SECRET_KEY=__SECRET_KEY__
|
|
||||||
RAILS_ENV=__RAILS_ENV__
|
RAILS_ENV=__RAILS_ENV__
|
||||||
|
EXPOSED_PORT=__EXPOSED_PORT__
|
||||||
|
SECRET_KEY_BASE=__SECRET_KEY__
|
||||||
|
RAILS_SERVE_STATIC_FILES=true
|
||||||
|
|
||||||
# Extensions Settings
|
# Extensions Settings
|
||||||
EXTENSIONS_MANAGER_LOCATION=__EXTENSIONS_MANAGER_LOCATION__
|
EXTENSIONS_MANAGER_LOCATION=__EXTENSIONS_MANAGER_LOCATION__
|
||||||
|
|
|
@ -12,7 +12,8 @@ Environment="PORT=__PORT_WEB__"
|
||||||
#ExecStart=/opt/yunohost/snserver/rails s >> /var/log/snserver/snserver.log 2>&1
|
#ExecStart=/opt/yunohost/snserver/rails s >> /var/log/snserver/snserver.log 2>&1
|
||||||
#ExecStart=__FINALPATH__/bin/rails s -e production >> /var/log/__APP__/__APP__.log 2>&1
|
#ExecStart=__FINALPATH__/bin/rails s -e production >> /var/log/__APP__/__APP__.log 2>&1
|
||||||
#ExecStart=/opt/rbenv/versions/2.6.5/bin/bundle exec puma -C config/puma.rb
|
#ExecStart=/opt/rbenv/versions/2.6.5/bin/bundle exec puma -C config/puma.rb
|
||||||
ExecStart=/opt/rbenv/versions/2.6.5/bin/rails s -b 0.0.0.0 >> /var/log/__APP__/__APP__.log 2>&1
|
#ExecStart=/opt/rbenv/versions/2.6.5/bin/rails s -b 0.0.0.0 >> /var/log/__APP__/__APP__.log 2>&1
|
||||||
|
ExecStart=/opt/rbenv/versions/2.6.5/bin/rails s -b 0.0.0.0
|
||||||
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
ExecReload=/bin/kill -SIGUSR1 $MAINPID
|
||||||
StandardError=syslog
|
StandardError=syslog
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
|
@ -73,6 +73,16 @@
|
||||||
},
|
},
|
||||||
"choices": ["en", "fr", "de"],
|
"choices": ["en", "fr", "de"],
|
||||||
"default": "en"
|
"default": "en"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "server_domain",
|
||||||
|
"type": "string",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose a server domain name for snweb",
|
||||||
|
"fr": "Choisissez un server domaine pour snweb",
|
||||||
|
"de": "Wähle einen Server Domain Namen für snweb"
|
||||||
|
},
|
||||||
|
"example": "sync.standardnotes.org"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
#pkg_dependencies="ruby ruby-dev rails zlib1g-dev libsqlite3-dev default-libmysqlclient-dev libssl-dev libreadline-dev"
|
#pkg_dependencies="ruby ruby-dev rails zlib1g-dev libsqlite3-dev default-libmysqlclient-dev libssl-dev libreadline-dev"
|
||||||
#pkg_dependencies=" zlib1g-dev libsqlite3-dev default-libmysqlclient-dev libssl-dev libreadline-dev"
|
#pkg_dependencies=" zlib1g-dev libsqlite3-dev default-libmysqlclient-dev libssl-dev libreadline-dev"
|
||||||
pkg_dependencies=""
|
#pkg_dependencies="libssl-dev libreadline-dev zlib1g-dev"
|
||||||
|
pkg_dependencies="git curl libssl-dev libreadline-dev zlib1g-dev autoconf bison build-essential libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
@ -16,14 +17,14 @@ pkg_dependencies=""
|
||||||
# Execute a command as another user with login
|
# Execute a command as another user with login
|
||||||
# (hence in user home dir, with prior loading of .profile, etc.)
|
# (hence in user home dir, with prior loading of .profile, etc.)
|
||||||
# usage: exec_login_as USER COMMAND [ARG ...]
|
# usage: exec_login_as USER COMMAND [ARG ...]
|
||||||
exec_login_as() {
|
ynh_exec_login_as() {
|
||||||
local user=$1
|
local user=$1
|
||||||
shift 1
|
shift 1
|
||||||
exec_as $user --login "$@"
|
exec_as $user --login "$@"
|
||||||
}
|
}
|
||||||
# Execute a command as another user
|
# Execute a command as another user
|
||||||
# usage: exec_as USER COMMAND [ARG ...]
|
# usage: exec_as USER COMMAND [ARG ...]
|
||||||
exec_as() {
|
ynh_exec_as() {
|
||||||
local user=$1
|
local user=$1
|
||||||
shift 1
|
shift 1
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
language=$YNH_APP_ARG_LANGUAGE
|
language=$YNH_APP_ARG_LANGUAGE
|
||||||
admin_mail=$(ynh_user_get_info $admin 'mail')
|
admin_mail=$(ynh_user_get_info $admin 'mail')
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
server_domain=$YNH_APP_ARG_SERVER_DOMAIN
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
@ -141,7 +142,6 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
# Download, check integrity, uncompress and patch the source from app.src
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
mkdir $final_path
|
mkdir $final_path
|
||||||
ynh_setup_source --dest_dir="$final_path/live"
|
ynh_setup_source --dest_dir="$final_path/live"
|
||||||
#ynh_setup_source --dest_dir="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# NGINX CONFIGURATION
|
# NGINX CONFIGURATION
|
||||||
|
@ -149,9 +149,10 @@ ynh_setup_source --dest_dir="$final_path/live"
|
||||||
ynh_script_progression --message="Configuring nginx web server..." --time --weight=2
|
ynh_script_progression --message="Configuring nginx web server..." --time --weight=2
|
||||||
|
|
||||||
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
### `ynh_add_nginx_config` will use the file conf/nginx.conf
|
||||||
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port_web" --target_file="../conf/nginx.conf"
|
||||||
|
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config 'port_web'
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# CREATE DEDICATED USER
|
||||||
|
@ -161,9 +162,9 @@ ynh_script_progression --message="Configuring system user..." --time --weight=2
|
||||||
# Create a system user
|
# Create a system user
|
||||||
#ynh_system_user_create --username=$app
|
#ynh_system_user_create --username=$app
|
||||||
# Create a system user allowing login
|
# Create a system user allowing login
|
||||||
#ynh_system_user_create $app $final_path 1
|
ynh_system_user_create $app $final_path 1
|
||||||
# Create a system user
|
# Create a system user
|
||||||
ynh_system_user_create --username=$app --home_dir=$final_path
|
#ynh_system_user_create --username=$app --home_dir=$final_path
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -175,10 +176,13 @@ ynh_script_progression --message="Installing Ruby..." --time --weight=321
|
||||||
|
|
||||||
ruby_version="2.6.5"
|
ruby_version="2.6.5"
|
||||||
ynh_install_ruby --ruby_version=$ruby_version
|
ynh_install_ruby --ruby_version=$ruby_version
|
||||||
|
|
||||||
/opt/rbenv/versions/$ruby_version/bin/gem update --system
|
/opt/rbenv/versions/$ruby_version/bin/gem update --system
|
||||||
/opt/rbenv/versions/$ruby_version/bin/gem install bundler --no-document
|
/opt/rbenv/versions/$ruby_version/bin/gem install bundler:1.17.1 --no-document
|
||||||
/opt/rbenv/versions/$ruby_version/bin/gem install bundle --no-document
|
/opt/rbenv/versions/$ruby_version/bin/gem install bundle --no-document
|
||||||
/opt/rbenv/versions/$ruby_version/bin/gem install rails --no-document
|
/opt/rbenv/versions/$ruby_version/bin/gem install rails --no-document
|
||||||
|
/opt/rbenv/versions/$ruby_version/bin/gem install haml --no-document
|
||||||
|
/opt/rbenv/versions/$ruby_version/bin/gem install sass --no-document
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
|
@ -188,8 +192,8 @@ ynh_script_progression --message="Modifying a config file..." --time --weight=2
|
||||||
### (It's compatible with sed regular expressions syntax)
|
### (It's compatible with sed regular expressions syntax)
|
||||||
|
|
||||||
|
|
||||||
cp -f ../conf/env.sample "$final_path/live/.env"
|
cp -f ../conf/env.sample "$final_path/live/.env.production"
|
||||||
config_file="$final_path/live/.env"
|
config_file="$final_path/live/.env.production"
|
||||||
|
|
||||||
ynh_replace_string --match_string="__EXPOSED_PORT__" --replace_string="$port_web" --target_file="$config_file"
|
ynh_replace_string --match_string="__EXPOSED_PORT__" --replace_string="$port_web" --target_file="$config_file"
|
||||||
secret_key=$(ynh_string_random --length=48 | base64)
|
secret_key=$(ynh_string_random --length=48 | base64)
|
||||||
|
@ -197,13 +201,7 @@ ynh_replace_string --match_string="__SECRET_KEY__" --replace_string="$secret_key
|
||||||
ynh_replace_string --match_string="__RAILS_ENV__" --replace_string="production" --target_file="$config_file"
|
ynh_replace_string --match_string="__RAILS_ENV__" --replace_string="production" --target_file="$config_file"
|
||||||
ynh_replace_string --match_string="__EXTENSIONS_MANAGER_LOCATION__" --replace_string="extensions/extensions-manager/dist/index.html" --target_file="$config_file"
|
ynh_replace_string --match_string="__EXTENSIONS_MANAGER_LOCATION__" --replace_string="extensions/extensions-manager/dist/index.html" --target_file="$config_file"
|
||||||
ynh_replace_string --match_string="__BATCH_MANAGER_LOCATION__" --replace_string="extensions/batch-manager/dist/index.min.html" --target_file="$config_file"
|
ynh_replace_string --match_string="__BATCH_MANAGER_LOCATION__" --replace_string="extensions/batch-manager/dist/index.min.html" --target_file="$config_file"
|
||||||
snserver_domain=(ynh_app_setting_get --app=snserver --key=domain)
|
ynh_replace_string --match_string="__SF_DEFAULT_SERVER__" --replace_string="https://$server_domain" --target_file="$config_file"
|
||||||
if [ "$snserver" = "" ]; then
|
|
||||||
snserver_domain="sync.standardnotes.org"
|
|
||||||
fi
|
|
||||||
ynh_replace_string --match_string="__SF_DEFAULT_SERVER__" --replace_string="https://$snserver_domain" --target_file="$config_file"
|
|
||||||
|
|
||||||
ynh_replace_string --match_string="__PORT__" --replace_string="$port_web;" --target_file="../conf/nginx.conf"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALLING Standard Notes - Synicing Server
|
# INSTALLING Standard Notes - Synicing Server
|
||||||
|
@ -214,13 +212,9 @@ chown -R "$app": "$final_path"
|
||||||
|
|
||||||
pushd "$final_path/live"
|
pushd "$final_path/live"
|
||||||
ynh_use_nodejs
|
ynh_use_nodejs
|
||||||
# sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/$ruby_version/bin/bundle config set path 'vendor/bundle'
|
ynh_exec_as "$app" env "PATH=$PATH" /opt/rbenv/versions/$ruby_version/bin/bundle install --path "vendor/bundle"
|
||||||
# sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/$ruby_version/bin/bundle config set with 'development'
|
ynh_exec_as "$app" env "PATH=$PATH:/opt/rbenv/versions/$ruby_version/bin:/var/www/snweb/live/vendor/bundle:/var/www/snweb/live/bin:$nodejs_path" yarn run build
|
||||||
# sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/$ruby_version/bin/bundle install --path "vendor/bundle"
|
ynh_exec_as "$app" env "PATH=$PATH" /opt/rbenv/versions/$ruby_version/bin/rails assets:precompile
|
||||||
#sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/$ruby_version/bin/bundle update --bundler
|
|
||||||
# sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile
|
|
||||||
#sudo -u "$app" env PATH=$PATH yarn run build --pure-lockfile
|
|
||||||
sudo -u "$app" npm run build
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -270,7 +264,9 @@ ynh_script_progression --message="Securing files and directories..." --time --we
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R root: $final_path
|
chown -R root: $final_path
|
||||||
chown $app: $final_path
|
chown $app: $final_path
|
||||||
|
chown $app: $final_path/live/
|
||||||
chown -R $app: $final_path/live/log/
|
chown -R $app: $final_path/live/log/
|
||||||
|
chown -R $app: $final_path/live/tmp/
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP LOGROTATE
|
# SETUP LOGROTATE
|
||||||
|
|
Loading…
Add table
Reference in a new issue