1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pixelfed_ynh.git synced 2024-09-03 20:06:04 +02:00

Fix install and removal

This commit is contained in:
yalh76 2019-03-29 05:56:59 +01:00
parent a6af8811c6
commit 4e7ec2952f
11 changed files with 117 additions and 238 deletions

View file

@ -30,6 +30,18 @@ Don't hesitate to give a hand if you wish, I assume only the nginx file needs im
![](https://camo.githubusercontent.com/c1c2e74057dcff57e103fcbb3239840802fcf752/68747470733a2f2f706978656c6665642e6e7963332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f6d656469612f53637265656e25323053686f74253230323031392d30322d30352532306174253230362e33342e3539253230504d2e706e67) ![](https://camo.githubusercontent.com/c1c2e74057dcff57e103fcbb3239840802fcf752/68747470733a2f2f706978656c6665642e6e7963332e63646e2e6469676974616c6f6365616e7370616365732e636f6d2f6d656469612f53637265656e25323053686f74253230323031392d30322d30352532306174253230362e33342e3539253230504d2e706e67)
## Configuration
### Administrator
After being first registered, you need to execute the folloing command to promote first registered as admin
**Run:**
$ (cd /var/www/pixelfed && php artisan user:admin 1)
and respond yes to the question ` Add admin privileges to this user?`
## Documentation ## Documentation
* Official documentation: https://docs.pixelfed.org/master/ * Official documentation: https://docs.pixelfed.org/master/

View file

@ -1,11 +1,10 @@
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld" (DOMAIN)
path="/path" (PATH)
is_public=1 (PUBLIC|public=1|private=0) is_public=1 (PUBLIC|public=1|private=0)
; Checks ; Checks
pkg_linter=1 pkg_linter=1
setup_sub_dir=1 setup_sub_dir=0
setup_root=1 setup_root=1
setup_nourl=0 setup_nourl=0
setup_private=0 setup_private=0

View file

@ -1,10 +1,13 @@
APP_NAME=__APP__ APP_NAME=__APP__
APP_ENV=local APP_ENV=production
APP_KEY= APP_KEY=
APP_DEBUG=true APP_DEBUG=true
APP_URL=http://__DOMAIN____PATH__ APP_URL=https://__DOMAIN__
LOG_CHANNEL=stackouille ADMIN_DOMAIN="__DOMAIN__"
APP_DOMAIN="__DOMAIN__"
LOG_CHANNEL=stack
DB_CONNECTION=pgsql DB_CONNECTION=pgsql
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
@ -14,36 +17,56 @@ DB_USERNAME=__DB_USER__
DB_PASSWORD=__DB_PWD__ DB_PASSWORD=__DB_PWD__
BROADCAST_DRIVER=log BROADCAST_DRIVER=log
CACHE_DRIVER=file CACHE_DRIVER=redis
SESSION_DRIVER=file SESSION_DRIVER=redis
SESSION_LIFETIME=120 SESSION_LIFETIME=120
QUEUE_DRIVER=sync QUEUE_DRIVER=redis
REDIS_HOST=127.0.0.1 REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null REDIS_PASSWORD=null
REDIS_PORT=6379 REDIS_PORT=6379
MAIL_DRIVER=smtp MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io MAIL_HOST=localhost
MAIL_PORT=2525 MAIL_PORT=25
MAIL_USERNAME=null MAIL_USERNAME=null
MAIL_PASSWORD=null MAIL_PASSWORD=null
MAIL_ENCRYPTION=null MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="pixelfed@__DOMAIN__"
MAIL_FROM_NAME="Pixelfed"
SESSION_DOMAIN="${APP_DOMAIN}"
SESSION_SECURE_COOKIE=true
API_BASE="/api/1/"
API_SEARCH="/api/search"
OPEN_REGISTRATION=true
RECAPTCHA_ENABLED=false
ENFORCE_EMAIL_VERIFICATION=true
PUSHER_APP_ID= PUSHER_APP_ID=
PUSHER_APP_KEY= PUSHER_APP_KEY=
PUSHER_APP_SECRET= PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1 PUSHER_APP_CLUSTER=mt1
SESSION_DOMAIN=".pixelfed.dev" MAX_PHOTO_SIZE=15000
SESSION_SECURE_COOKIE=true MAX_CAPTION_LENGTH=150
API_BASE="/api/1/" MAX_ALBUM_LENGTH=4
API_SEARCH="/api/search"
OPEN_REGISTRATION=true
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_APP_URL="${APP_URL}" MIX_APP_URL="${APP_URL}"
MIX_API_BASE="${API_BASE}" MIX_API_BASE="${API_BASE}"
MIX_API_SEARCH="${API_SEARCH}" MIX_API_SEARCH="${API_SEARCH}"
ACTIVITYPUB_INBOX=false
ACTIVITYPUB_SHAREDINBOX=false
HORIZON_DARKMODE=true
# Set these both "true" to enable federation.
# You might need to also run:
# php artisan cache:clear
# php artisan optimize:clear
# php artisan optimize
ACTIVITY_PUB=false
REMOTE_FOLLOW=false

View file

@ -1,5 +1,5 @@
SOURCE_URL=https://github.com/pixelfed/pixelfed/archive/12857575550a0c86a11ce1445835dcede4d37150.tar.gz SOURCE_URL=https://github.com/pixelfed/pixelfed/archive/ac53aea28884f0c49c110ac6d87a7b40e92171c9.tar.gz
SOURCE_SUM=9228d2d0154c998f584e168ffff4a76205c3212e6c282203add136c371d931bd SOURCE_SUM=ca6156026eb1bb8d8995d247a895b88078e93f1127b75af07058d74f57830846
OURCE_SUM_PRG=sha256sum OURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true SOURCE_IN_SUBDIR=true

View file

@ -1,36 +1,33 @@
location __PATH__ { location __PATH__ {
# Path to source # Path to source
alias __FINALPATH__/public/ ; alias __FINALPATH__/public/ ;
try_files $uri $uri/ @pixelfed;
if ($scheme = http) { # Force usage of https
rewrite ^ https://$server_name$request_uri? permanent; if ($scheme = http) {
} rewrite ^ https://$server_name$request_uri? permanent;
}
index index.php; index index.php;
# Common parameter to increase upload size limit in conjuction with dedicated php-fpm file # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
#client_max_body_size 50M; #client_max_body_size 50M;
try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) {
location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.2-fpm-__NAME__.sock;
fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock;
# If you don't use a dedicated fpm config for your app, fastcgi_index index.php;
# use a general fpm pool. include fastcgi_params;
# This is to be used INSTEAD of line above fastcgi_param REMOTE_USER $remote_user;
# Don't forget to adjust scripts install/upgrade/remove/backup accordingly fastcgi_param PATH_INFO $fastcgi_path_info;
# fastcgi_param SCRIPT_FILENAME $request_filename;
#fastcgi_pass unix:/var/run/php5-fpm.sock; }
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
# Include SSOWAT user panel. # Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }
location @pixelfed {
rewrite /(.*)$ /index.php?/$1 last;
}

View file

@ -33,7 +33,7 @@ group = __USER__
; (IPv6 and IPv4-mapped) on a specific port; ; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket. ; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory. ; Note: This value is mandatory.
listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock listen = /var/run/php/php7.2-fpm-__NAMETOCHANGE__.sock
; Set listen(2) backlog. ; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD) ; Default Value: 511 (-1 on FreeBSD and OpenBSD)

View file

@ -31,16 +31,6 @@
}, },
"example": "domain.org" "example": "domain.org"
}, },
{
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for Pixelfed",
"fr": "Choisissez un chemin pour Pixelfed"
},
"example": "/pixelfed",
"default": "/pixelfed"
},
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",

View file

@ -5,7 +5,11 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="php7.2-mbstring postgresql redis-server" pkg_dependencies="php7.2-pgsql php7.2-mbstring php7.2-bcmath php7.2-simplexml php7.2-curl postgresql redis-server \
php7.2-intl php7.2-exif \
libfreetype6 libjpeg62-turbo libpng16-16 libxpm4 libvpx4 libwebp6 libmagickwand-6.q16-3 \
php7.2-imagick imagick \
pngquant jpegoptim gifsicle"
#================================================= #=================================================
# PERSONAL HELPERS # PERSONAL HELPERS

View file

@ -1,160 +0,0 @@
#!/bin/bash
#=================================================
#
# POSTGRES HELPERS
#
# Point of contact : Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
#=================================================
# Create a master password and set up global settings
# Please always call this script in install and restore scripts
#
# usage: ynh_psql_test_if_first_run
ynh_psql_test_if_first_run() {
if [ -f /etc/yunohost/psql ];
then
echo "PostgreSQL is already installed, no need to create master password"
else
pgsql=$(ynh_string_random)
pg_hba=""
echo "$pgsql" >> /etc/yunohost/psql
if [ -e /etc/postgresql/9.4/ ]
then
pg_hba=/etc/postgresql/9.4/main/pg_hba.conf
elif [ -e /etc/postgresql/9.6/ ]
then
pg_hba=/etc/postgresql/9.6/main/pg_hba.conf
else
ynh_die "postgresql shoud be 9.4 or 9.6"
fi
systemctl start postgresql
sudo --login --user=postgres psql -c"ALTER user postgres WITH PASSWORD '$pgsql'" postgres
# force all user to connect to local database using passwords
# https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html#EXAMPLE-PG-HBA.CONF
# Note: we can't use peer since YunoHost create users with nologin
# See: https://github.com/YunoHost/yunohost/blob/unstable/data/helpers.d/user
sed -i '/local\s*all\s*all\s*peer/i \
local all all password' "$pg_hba"
systemctl enable postgresql
systemctl reload postgresql
fi
}
# Open a connection as a user
#
# example: ynh_psql_connect_as 'user' 'pass' <<< "UPDATE ...;"
# example: ynh_psql_connect_as 'user' 'pass' < /path/to/file.sql
#
# usage: ynh_psql_connect_as user pwd [db]
# | arg: user - the user name to connect as
# | arg: pwd - the user password
# | arg: db - the database to connect to
ynh_psql_connect_as() {
local user="$1"
local pwd="$2"
local db="$3"
sudo --login --user=postgres PGUSER="$user" PGPASSWORD="$pwd" psql "$db"
}
# # Execute a command as root user
#
# usage: ynh_psql_execute_as_root sql [db]
# | arg: sql - the SQL command to execute
# | arg: db - the database to connect to
ynh_psql_execute_as_root () {
local sql="$1"
sudo --login --user=postgres psql <<< "$sql"
}
# Execute a command from a file as root user
#
# usage: ynh_psql_execute_file_as_root file [db]
# | arg: file - the file containing SQL commands
# | arg: db - the database to connect to
ynh_psql_execute_file_as_root() {
local file="$1"
local db="$2"
sudo --login --user=postgres psql "$db" < "$file"
}
# Create a database, an user and its password. Then store the password in the app's config
#
# After executing this helper, the password of the created database will be available in $db_pwd
# It will also be stored as "psqlpwd" into the app settings.
#
# usage: ynh_psql_setup_db user name [pwd]
# | arg: user - Owner of the database
# | arg: name - Name of the database
# | arg: pwd - Password of the database. If not given, a password will be generated
ynh_psql_setup_db () {
local db_user="$1"
local db_name="$2"
local new_db_pwd=$(ynh_string_random) # Generate a random password
# If $3 is not given, use new_db_pwd instead for db_pwd.
local db_pwd="${3:-$new_db_pwd}"
ynh_psql_create_db "$db_name" "$db_user" "$db_pwd" # Create the database
ynh_app_setting_set "$app" psqlpwd "$db_pwd" # Store the password in the app's config
}
# Create a database and grant privilegies to a user
#
# usage: ynh_psql_create_db db [user [pwd]]
# | arg: db - the database name to create
# | arg: user - the user to grant privilegies
# | arg: pwd - the user password
ynh_psql_create_db() {
local db="$1"
local user="$2"
local pwd="$3"
ynh_psql_create_user "$user" "$pwd"
sudo --login --user=postgres createdb --owner="$user" "$db"
}
# Drop a database
#
# usage: ynh_psql_drop_db db
# | arg: db - the database name to drop
# | arg: user - the user to drop
ynh_psql_remove_db() {
local db="$1"
local user="$2"
sudo --login --user=postgres dropdb "$db"
ynh_psql_drop_user "$user"
}
# Dump a database
#
# example: ynh_psql_dump_db 'roundcube' > ./dump.sql
#
# usage: ynh_psql_dump_db db
# | arg: db - the database name to dump
# | ret: the psqldump output
ynh_psql_dump_db() {
local db="$1"
sudo --login --user=postgres pg_dump "$db"
}
# Create a user
#
# usage: ynh_psql_create_user user pwd [host]
# | arg: user - the user name to create
ynh_psql_create_user() {
local user="$1"
local pwd="$2"
sudo --login --user=postgres psql -c"CREATE USER $user WITH PASSWORD '$pwd'" postgres
}
# Drop a user
#
# usage: ynh_psql_drop_user user
# | arg: user - the user name to drop
ynh_psql_drop_user() {
local user="$1"
sudo --login --user=postgres dropuser "$user"
}

View file

@ -7,7 +7,6 @@
#================================================= #=================================================
source _common.sh source _common.sh
source _pgsql.sh
source ynh_install_php source ynh_install_php
source ynh_add_secure_repos__2 source ynh_add_secure_repos__2
source ynh_composer source ynh_composer
@ -25,7 +24,7 @@ ynh_abort_if_errors
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -56,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public
#================================================= #=================================================
ynh_print_info "Installing dependencies..." ynh_print_info "Installing dependencies..."
ynh_install_php --phpversion=7.2 ynh_install_php --phpversion="7.2"
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
@ -67,13 +66,13 @@ ynh_print_info "Creating a PostgreSQL database..."
ynh_psql_test_if_first_run ynh_psql_test_if_first_run
db_name=$(ynh_sanitize_dbid "$app") db_name=$(ynh_sanitize_dbid $app)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_string_random) db_pwd=$(ynh_string_random)
ynh_app_setting_set "$app" db_name "$db_name" ynh_app_setting_set $app db_name $db_name
# Initialize database and store postgres password for upgrade # Initialize database and store postgres password for upgrade
ynh_psql_setup_db "$db_name" "$db_user" ynh_psql_setup_db $db_user $db_name $db_pwd
systemctl reload postgresql systemctl reload postgresql
@ -104,9 +103,14 @@ ynh_system_user_create $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
#================================================= #=================================================
ynh_print_info "Configuring php-fpm..."
# Create a dedicated php-fpm config # Create a dedicated php-fpm config
ynh_add_fpm_config --phpversion=7.2 ynh_add_fpm_config --phpversion="7.2"
#Ugly move waiting 'ynh_add_fpm_config --phpversion='' released
mv /etc/php/7.0/fpm/pool.d/$app.conf /etc/php/7.2/fpm/pool.d/$app.conf
systemctl reload php7.2-fpm
#================================================= #=================================================
# INSTALL PHP DEPENDENCIES # INSTALL PHP DEPENDENCIES
@ -140,15 +144,19 @@ ynh_replace_string "__DB_PWD__" "$db_pwd" "$config"
ynh_store_file_checksum "$config" ynh_store_file_checksum "$config"
#================================================= #=================================================
# GENERATE KEY AND CLEAR CACHE # DEPLOYMENT
#================================================= #=================================================
# generate key and clear cache pushd $final_path
(
cd "$final_path"
php7.2 artisan -n key:generate --force php7.2 artisan -n key:generate --force
php7.2 artisan config:clear php7.2 artisan config:clear
) php7.2 artisan config:cache
php7.2 artisan route:cache
php7.2 artisan storage:link
php7.2 artisan migrate --force
php7.2 artisan update
php7.2 artisan horizon:purge
popd
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION

View file

@ -7,7 +7,6 @@
#================================================= #=================================================
source _common.sh source _common.sh
source _pgsql.sh
source ynh_install_php source ynh_install_php
source ynh_add_secure_repos__2 source ynh_add_secure_repos__2
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -31,8 +30,23 @@ final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
ynh_print_info "Removing the PostgreSQL database" ynh_print_info "Removing the PostgreSQL database"
ynh_psql_execute_as_root "\connect $db_name
SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';"
# Remove a database if it exists, along with the associated user # Remove a database if it exists, along with the associated user
ynh_psql_remove_db "$db_name" "$app" ynh_psql_remove_db $db_user $db_name
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Removing php-fpm configuration"
#Ugly move waiting 'ynh_add_fpm_config --phpversion='' released
mv /etc/php/7.2/fpm/pool.d/$app.conf /etc/php/7.0/fpm/pool.d/$app.conf
systemctl reload php7.2-fpm
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE DEPENDENCIES
@ -40,8 +54,8 @@ ynh_psql_remove_db "$db_name" "$app"
ynh_print_info "Removing dependencies" ynh_print_info "Removing dependencies"
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_php ynh_remove_php
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
@ -59,14 +73,6 @@ ynh_print_info "Removing nginx web server configuration"
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_print_info "Removing php-fpm configuration"
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================