1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/cachet_ynh.git synced 2024-09-03 18:16:03 +02:00

Add templates

This commit is contained in:
ericgaspar 2021-11-24 21:53:43 +01:00
parent dde7ea8add
commit c16b88f9e6
No known key found for this signature in database
GPG key ID: 574F281483054D44
7 changed files with 81 additions and 114 deletions

44
conf/.env Normal file
View file

@ -0,0 +1,44 @@
APP_ENV=production
APP_DEBUG=false
APP_URL=http://__DOMAIN____PATH__
APP_TIMEZONE=UTC
APP_KEY=__KEY__
DEBUGBAR_ENABLED=false
DB_DRIVER=mysql
DB_HOST=localhost
DB_UNIX_SOCKET=null
DB_DATABASE=__DB_NAME__
DB_USERNAME=__DB_USER__
DB_PASSWORD=__DB_PWD__
DB_PORT=null
DB_PREFIX=null
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
CACHET_BEACON=true
CACHET_EMOJI=false
CACHET_AUTO_TWITTER=true
MAIL_DRIVER=sendmail
MAIL_HOST=
MAIL_PORT=25
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ADDRESS=__EMAIL__
MAIL_NAME=null
MAIL_ENCRYPTION=tls
REDIS_HOST=null
REDIS_DATABASE=null
REDIS_PORT=null
GITHUB_TOKEN=null
NEXMO_KEY=null
NEXMO_SECRET=null
NEXMO_SMS_FROM=Cachet
TRUSTED_PROXIES=

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
[Cachet](https://cachethq.io/) is a free, open source status page for your API, service or company. Built with all of the features that you'd expect from a status page, Cachet comes with a powerful API, a metric system, multiple user support, two factor authentication for added security and is easy to get setup. A powerful, self-hosted alternative to StatusPage.io and Status.io.

3
doc/DISCLAIMER.md Normal file
View file

@ -0,0 +1,3 @@
## Configuration
Totally configurable through the Cachet application dashboard.

View file

@ -8,6 +8,13 @@
},
"version": "2.3.18~ynh2",
"url": "https://cachethq.io/",
"upstream": {
"license": "BSD-3-Clause",
"website": "https://cachethq.io/",
"demo": "https://demo.cachethq.io/",
"admindoc": "https://docs.cachethq.io/",
"code": "https://github.com/CachetHQ/Cachet"
},
"license": "BSD-3-Clause",
"maintainer": {
"name": "JimboJoe",
@ -33,7 +40,7 @@
"type": "user"
},
{
"name": "admin_password",
"name": "password",
"type": "password",
"optional": true
},

View file

@ -8,6 +8,9 @@ YNH_PHP_VERSION="7.3"
pkg_dependencies="php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-sqlite3"
# Composer version
YNH_COMPOSER_VERSION="1.10.17"
#=================================================
# PERSONAL HELPERS
#=================================================
@ -22,80 +25,3 @@ exec_artisan() {
# EXPERIMENTAL HELPERS
#=================================================
# Execute a command as another user
# usage: exec_as USER COMMAND [ARG ...]
ynh_exec_as() {
local USER=$1
shift 1
if [[ $USER = $(whoami) ]]; then
eval "$@"
else
sudo -u "$USER" "$@"
fi
}
readonly YNH_DEFAULT_COMPOSER_VERSION=1.10.17
# Declare the actual composer version to use.
# A packager willing to use another version of composer can override the variable into its _common.sh.
YNH_COMPOSER_VERSION=${YNH_COMPOSER_VERSION:-$YNH_DEFAULT_COMPOSER_VERSION}
# Execute a command with Composer
#
# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
# | arg: -v, --phpversion - PHP version to use with composer
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -c, --commands - Commands to execute.
ynh_composer_exec () {
# Declare an array to define the options of this helper.
local legacy_args=vwc
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [c]=commands= )
local phpversion
local workdir
local commands
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-$YNH_PHP_VERSION}"
COMPOSER_HOME="$workdir/.composer" \
php${phpversion} "$workdir/composer.phar" $commands \
-d "$workdir" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
#
# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] [--composerversion=composerversion]
# | arg: -v, --phpversion - PHP version to use with composer
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
# | arg: -c, --composerversion - Composer version to install
ynh_install_composer () {
# Declare an array to define the options of this helper.
local legacy_args=vwa
declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args= [c]=composerversion=)
local phpversion
local workdir
local install_args
local composerversion
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}"
phpversion="${phpversion:-$YNH_PHP_VERSION}"
install_args="${install_args:-}"
composerversion="${composerversion:-$YNH_COMPOSER_VERSION}"
curl -sS https://getcomposer.org/installer \
| COMPOSER_HOME="$workdir/.composer" \
php${phpversion} -- --quiet --install-dir="$workdir" --version=$composerversion \
|| ynh_die "Unable to install Composer."
# update dependencies to create composer.lock
ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \
|| ynh_die "Unable to update core dependencies with Composer."
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -27,9 +27,10 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
admin=$YNH_APP_ARG_ADMIN
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
password=$YNH_APP_ARG_PASSWORD
is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE
email=$(ynh_user_get_info $admin mail)
app=$YNH_APP_INSTANCE_NAME
@ -52,7 +53,7 @@ ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=admin_password --value=$admin_password
ynh_app_setting_set --app=$app --key=password --value=$password
ynh_app_setting_set --app=$app --key=language --value=$language
#=================================================
@ -106,34 +107,15 @@ ynh_script_progression --message="Configuring PHP-FPM..." --weight=8
ynh_add_fpm_config
#=================================================
# SPECIFIC SETUP
# ADD A CONFIGURATION
#=================================================
# PRE-CONFIGURE CACHET
#=================================================
ynh_script_progression --message="Configuring Cachet..." --weight=10
ynh_script_progression --message="Adding a configuration file..." --weight=1
env_conf="$final_path/.env"
key=$(ynh_string_random 24)
ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
cp $final_path/.env.example $env_conf
ynh_replace_string --match_string="APP_URL=http://localhost" --replace_string="APP_URL=https://$domain$path_url" --target_file="$env_conf"
ynh_replace_string --match_string="APP_KEY=SomeRandomString" --replace_string="APP_KEY=$(ynh_string_random 24)" --target_file="$env_conf"
ynh_replace_string --match_string="DB_DATABASE=cachet" --replace_string="DB_DATABASE=$db_name" --target_file="$env_conf"
ynh_replace_string --match_string="DB_USERNAME=homestead" --replace_string="DB_USERNAME=$db_name" --target_file="$env_conf"
ynh_replace_string --match_string="DB_PASSWORD=secret" --replace_string="DB_PASSWORD=$db_pwd" --target_file="$env_conf"
ynh_replace_string --match_string="MAIL_DRIVER=log" --replace_string="MAIL_DRIVER=sendmail" --target_file="$env_conf"
ynh_replace_string --match_string="MAIL_HOST=null" --replace_string="MAIL_HOST=" --target_file="$env_conf"
ynh_replace_string --match_string="MAIL_PORT=null" --replace_string="MAIL_PORT=25" --target_file="$env_conf"
ynh_replace_string --match_string="MAIL_USERNAME=null" --replace_string="MAIL_USERNAME=null" --target_file="$env_conf"
ynh_replace_string --match_string="MAIL_PASSWORD=null" --replace_string="MAIL_PASSWORD=null" --target_file="$env_conf"
admin_mail="$(ynh_user_get_info $admin mail)"
ynh_replace_string --match_string="MAIL_ADDRESS=null" --replace_string="MAIL_ADDRESS=$admin_mail" --target_file="$env_conf"
ynh_replace_string --match_string="MAIL_NAME=null" --replace_string="MAIL_NAME=$admin" --target_file="$env_conf"
# Disable reporting to CachetHQ servers
ynh_replace_string --match_string="CACHET_BEACON=true" --replace_string="CACHET_BEACON=false" --target_file="$env_conf"
ynh_store_file_checksum "$env_conf"
chmod 400 "$final_path/some_config_file"
chown $app:$app "$final_path/some_config_file"
#=================================================
# INSTALL AND INITIALIZE COMPOSER
@ -182,8 +164,9 @@ ynh_store_file_checksum --file="$production_conf"
#=================================================
# Set permissions to app files
chown -R root: $final_path
chown -R $app: "${final_path}/.env" "${final_path}/storage/" "${final_path}/bootstrap/"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SETUP SSOWAT

View file

@ -124,16 +124,18 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." -
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=6
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# SPECIFIC UPGRADE
#=================================================
ynh_script_progression --message="Upgrading Cachet configuration and dependencies..." --weight=20
#=================================================
# INSTALL AND INITIALIZE COMPOSER
#=================================================
ynh_install_composer --install_args="--optimize-autoloader"
#=================================================
@ -150,8 +152,9 @@ ynh_secure_remove --file=bootstrap/cache/*
#=================================================
# Set permissions on app files
chown -R root: $final_path
chown -R $app: "${final_path}/.env" "${final_path}/storage/" "${final_path}/bootstrap/"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SET MAINTENANCE MODE OFF