mirror of
https://github.com/YunoHost-Apps/lemmy_ynh.git
synced 2024-09-03 19:36:09 +02:00
Initial commit
This commit is contained in:
parent
2b5257e690
commit
a909f57c5b
16 changed files with 1134 additions and 0 deletions
|
@ -1,2 +1,4 @@
|
||||||
# lemmy_ynh
|
# lemmy_ynh
|
||||||
A link aggregator for the fediverse.
|
A link aggregator for the fediverse.
|
||||||
|
|
||||||
|
APP not ready yet.
|
||||||
|
|
31
check_process
Normal file
31
check_process
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# See here for more information
|
||||||
|
# https://github.com/YunoHost/package_check#syntax-check_process-file
|
||||||
|
|
||||||
|
# Move this file from check_process.default to check_process when you have filled it.
|
||||||
|
|
||||||
|
;; Test complet
|
||||||
|
; Manifest
|
||||||
|
domain="domain.tld" (DOMAIN)
|
||||||
|
path="/path" (PATH)
|
||||||
|
admin="john" (USER)
|
||||||
|
sitename="lemmy website) (SITENAME)
|
||||||
|
; Checks
|
||||||
|
pkg_linter=1
|
||||||
|
setup_sub_dir=0
|
||||||
|
setup_root=1
|
||||||
|
setup_nourl=0
|
||||||
|
setup_private=0
|
||||||
|
setup_public=1
|
||||||
|
upgrade=1
|
||||||
|
#upgrade=1 from_commit=CommitHash
|
||||||
|
backup_restore=1
|
||||||
|
multi_instance=1
|
||||||
|
port_already_use=0
|
||||||
|
change_url=0
|
||||||
|
;;; Options
|
||||||
|
Email=
|
||||||
|
Notification=none
|
||||||
|
;;; Upgrade options
|
||||||
|
; commit=CommitHash
|
||||||
|
name=Name and date of the commit.
|
||||||
|
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
7
conf/app.src
Normal file
7
conf/app.src
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
SOURCE_URL=url of app's source
|
||||||
|
SOURCE_SUM=sha256 checksum
|
||||||
|
SOURCE_SUM_PRG=sha256sum
|
||||||
|
SOURCE_FORMAT=tar.gz
|
||||||
|
SOURCE_IN_SUBDIR=true
|
||||||
|
SOURCE_FILENAME=
|
||||||
|
SOURCE_EXTRACT=true
|
56
conf/docker-compose.yml
Normal file
56
conf/docker-compose.yml
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
version: "2.2"
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:12-alpine
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=lemmy
|
||||||
|
- POSTGRES_PASSWORD=password
|
||||||
|
- POSTGRES_DB=lemmy
|
||||||
|
volumes:
|
||||||
|
- ./volumes/postgres:/var/lib/postgresql/data
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
lemmy:
|
||||||
|
image: dessalines/lemmy:0.9.9
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:__PORT__LEMMY__:8536"
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- RUST_LOG=error
|
||||||
|
volumes:
|
||||||
|
- ./lemmy.hjson:/config/config.hjson
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
- pictrs
|
||||||
|
- iframely
|
||||||
|
|
||||||
|
lemmy-ui:
|
||||||
|
image: dessalines/lemmy-ui:0.9.9
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:__PORT_UI__:1234"
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- LEMMY_INTERNAL_HOST=lemmy:8536
|
||||||
|
- LEMMY_EXTERNAL_HOST=localhost:__PORT__LEMMY__
|
||||||
|
- LEMMY_HTTPS=false
|
||||||
|
depends_on:
|
||||||
|
- lemmy
|
||||||
|
|
||||||
|
pictrs:
|
||||||
|
image: asonix/pictrs:v0.2.5-r0
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:__PORT_PICTRS__:8080"
|
||||||
|
user: 991:991
|
||||||
|
volumes:
|
||||||
|
- ./volumes/pictrs:/mnt
|
||||||
|
restart: always
|
||||||
|
|
||||||
|
iframely:
|
||||||
|
image: dogbin/iframely:latest
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:__PORT_IFRAMELY__:80"
|
||||||
|
volumes:
|
||||||
|
- ./iframely.config.local.js:/iframely/config.local.js:ro
|
||||||
|
restart: always
|
||||||
|
mem_limit: 100m
|
283
conf/iframely.config.local.js
Normal file
283
conf/iframely.config.local.js
Normal file
|
@ -0,0 +1,283 @@
|
||||||
|
(function() {
|
||||||
|
var config = {
|
||||||
|
|
||||||
|
// Specify a path for custom plugins. Custom plugins will override core plugins.
|
||||||
|
// CUSTOM_PLUGINS_PATH: __dirname + '/yourcustom-plugin-folder',
|
||||||
|
|
||||||
|
DEBUG: false,
|
||||||
|
RICH_LOG_ENABLED: false,
|
||||||
|
|
||||||
|
// For embeds that require render, baseAppUrl will be used as the host.
|
||||||
|
baseAppUrl: "http://__DOMAIN__",
|
||||||
|
relativeStaticUrl: "/r",
|
||||||
|
|
||||||
|
// Or just skip built-in renders altogether
|
||||||
|
SKIP_IFRAMELY_RENDERS: true,
|
||||||
|
|
||||||
|
// For legacy reasons the response format of Iframely open-source is
|
||||||
|
// different by default as it does not group the links array by rel.
|
||||||
|
// In order to get the same grouped response as in Cloud API,
|
||||||
|
// add `&group=true` to your request to change response per request
|
||||||
|
// or set `GROUP_LINKS` in your config to `true` for a global change.
|
||||||
|
GROUP_LINKS: true,
|
||||||
|
|
||||||
|
// Number of maximum redirects to follow before aborting the page
|
||||||
|
// request with `redirect loop` error.
|
||||||
|
MAX_REDIRECTS: 4,
|
||||||
|
|
||||||
|
SKIP_OEMBED_RE_LIST: [
|
||||||
|
// /^https?:\/\/yourdomain\.com\//,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Used to pass parameters to the generate functions when creating HTML elements
|
||||||
|
// disableSizeWrapper: Don't wrap element (iframe, video, etc) in a positioned div
|
||||||
|
GENERATE_LINK_PARAMS: {
|
||||||
|
disableSizeWrapper: true
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
port: 80, //can be overridden by PORT env var
|
||||||
|
host: '0.0.0.0', // Dockers beware. See https://github.com/itteco/iframely/issues/132#issuecomment-242991246
|
||||||
|
//can be overridden by HOST env var
|
||||||
|
|
||||||
|
// Optional SSL cert, if you serve under HTTPS.
|
||||||
|
/*
|
||||||
|
ssl: {
|
||||||
|
key: require('fs').readFileSync(__dirname + '/key.pem'),
|
||||||
|
cert: require('fs').readFileSync(__dirname + '/cert.pem'),
|
||||||
|
port: 443
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Supported cache engines:
|
||||||
|
- no-cache - no caching will be used.
|
||||||
|
- node-cache - good for debug, node memory will be used (https://github.com/tcs-de/nodecache).
|
||||||
|
- redis - https://github.com/mranney/node_redis.
|
||||||
|
- memcached - https://github.com/3rd-Eden/node-memcached
|
||||||
|
*/
|
||||||
|
CACHE_ENGINE: 'node-cache',
|
||||||
|
CACHE_TTL: 0, // In seconds.
|
||||||
|
// 0 = 'never expire' for memcached & node-cache to let cache engine decide itself when to evict the record
|
||||||
|
// 0 = 'no cache' for redis. Use high enough (e.g. 365*24*60*60*1000) ttl for similar 'never expire' approach instead
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Redis cache options.
|
||||||
|
REDIS_OPTIONS: {
|
||||||
|
host: '127.0.0.1',
|
||||||
|
port: 6379
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Memcached options. See https://github.com/3rd-Eden/node-memcached#server-locations
|
||||||
|
MEMCACHED_OPTIONS: {
|
||||||
|
locations: "127.0.0.1:11211"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Access-Control-Allow-Origin list.
|
||||||
|
allowedOrigins: [
|
||||||
|
"*",
|
||||||
|
"http://another_domain.com"
|
||||||
|
],
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Uncomment to enable plugin testing framework.
|
||||||
|
tests: {
|
||||||
|
mongodb: 'mongodb://localhost:27017/iframely-tests',
|
||||||
|
single_test_timeout: 10 * 1000,
|
||||||
|
plugin_test_period: 2 * 60 * 60 * 1000,
|
||||||
|
relaunch_script_period: 5 * 60 * 1000
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
// If there's no response from remote server, the timeout will occur after
|
||||||
|
RESPONSE_TIMEOUT: 5 * 1000, //ms
|
||||||
|
|
||||||
|
/* From v1.4.0, Iframely supports HTTP/2 by default. Disable it, if you'd rather not.
|
||||||
|
Alternatively, you can also disable per origin. See `proxy` option below.
|
||||||
|
*/
|
||||||
|
// DISABLE_HTTP2: true,
|
||||||
|
|
||||||
|
// Customize API calls to oembed endpoints.
|
||||||
|
ADD_OEMBED_PARAMS: [{
|
||||||
|
// Endpoint url regexp array.
|
||||||
|
re: [/^http:\/\/api\.instagram\.com\/oembed/],
|
||||||
|
// Custom get params object.
|
||||||
|
params: {
|
||||||
|
hidecaption: true
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
re: [/^https:\/\/www\.facebook\.com\/plugins\/page\/oembed\.json/i],
|
||||||
|
params: {
|
||||||
|
show_posts: 0,
|
||||||
|
show_facepile: 0,
|
||||||
|
maxwidth: 600
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
// match i=user or i=moment or i=timeline to configure these types invidually
|
||||||
|
// see params spec at https://dev.twitter.com/web/embedded-timelines/oembed
|
||||||
|
re: [/^https?:\/\/publish\.twitter\.com\/oembed\?i=user/i],
|
||||||
|
params: {
|
||||||
|
limit: 1,
|
||||||
|
maxwidth: 600
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
}, {
|
||||||
|
// Facebook https://developers.facebook.com/docs/plugins/oembed-endpoints
|
||||||
|
re: [/^https:\/\/www\.facebook\.com\/plugins\/\w+\/oembed\.json/i],
|
||||||
|
params: {
|
||||||
|
// Skip script tag and fb-root div.
|
||||||
|
omitscript: true
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}],
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Configure use of HTTP proxies as needed.
|
||||||
|
// You don't have to specify all options per regex - just what you need to override
|
||||||
|
PROXY: [{
|
||||||
|
re: [/^https?:\/\/www\.domain\.com/],
|
||||||
|
proxy_server: 'http://1.2.3.4:8080',
|
||||||
|
user_agent: 'CHANGE YOUR AGENT',
|
||||||
|
headers: {
|
||||||
|
// HTTP headers
|
||||||
|
// Overrides previous params if overlapped.
|
||||||
|
},
|
||||||
|
request_options: {
|
||||||
|
// Refer to: https://github.com/request/request
|
||||||
|
// Overrides previous params if overlapped.
|
||||||
|
},
|
||||||
|
disable_http2: true
|
||||||
|
}],
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Customize API calls to 3rd parties. At the very least - configure required keys.
|
||||||
|
providerOptions: {
|
||||||
|
locale: "en_US", // ISO 639-1 two-letter language code, e.g. en_CA or fr_CH.
|
||||||
|
// Will be added as highest priotity in accept-language header with each request.
|
||||||
|
// Plus is used in FB, YouTube and perhaps other plugins
|
||||||
|
"twitter": {
|
||||||
|
"max-width": 550,
|
||||||
|
"min-width": 250,
|
||||||
|
hide_media: false,
|
||||||
|
hide_thread: false,
|
||||||
|
omit_script: false,
|
||||||
|
center: false,
|
||||||
|
// dnt: true,
|
||||||
|
cache_ttl: 100 * 365 * 24 * 3600 // 100 Years.
|
||||||
|
},
|
||||||
|
readability: {
|
||||||
|
enabled: false
|
||||||
|
// allowPTagDescription: true // to enable description fallback to first paragraph
|
||||||
|
},
|
||||||
|
images: {
|
||||||
|
loadSize: false, // if true, will try an load first bytes of all images to get/confirm the sizes
|
||||||
|
checkFavicon: false // if true, will verify all favicons
|
||||||
|
},
|
||||||
|
tumblr: {
|
||||||
|
consumer_key: "INSERT YOUR VALUE"
|
||||||
|
// media_only: true // disables status embeds for images and videos - will return plain media
|
||||||
|
},
|
||||||
|
google: {
|
||||||
|
// https://developers.google.com/maps/documentation/embed/guide#api_key
|
||||||
|
maps_key: "INSERT YOUR VALUE"
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Optional Camo Proxy to wrap all images: https://github.com/atmos/camo
|
||||||
|
camoProxy: {
|
||||||
|
camo_proxy_key: "INSERT YOUR VALUE",
|
||||||
|
camo_proxy_host: "INSERT YOUR VALUE"
|
||||||
|
// ssl_only: true // will only proxy non-ssl images
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
// List of query parameters to add to YouTube and Vimeo frames
|
||||||
|
// Start it with leading "?". Or omit alltogether for default values
|
||||||
|
// API key is optional, youtube will work without it too.
|
||||||
|
// It is probably the same API key you use for Google Maps.
|
||||||
|
youtube: {
|
||||||
|
// api_key: "INSERT YOUR VALUE",
|
||||||
|
get_params: "?rel=0&showinfo=1" // https://developers.google.com/youtube/player_parameters
|
||||||
|
},
|
||||||
|
vimeo: {
|
||||||
|
get_params: "?byline=0&badge=0" // https://developer.vimeo.com/player/embedding
|
||||||
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
soundcloud: {
|
||||||
|
old_player: true // enables classic player
|
||||||
|
},
|
||||||
|
giphy: {
|
||||||
|
media_only: true // disables branded player for gifs and returns just the image
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
bandcamp: {
|
||||||
|
get_params: '/size=large/bgcol=333333/linkcol=ffffff/artwork=small/transparent=true/',
|
||||||
|
media: {
|
||||||
|
album: {
|
||||||
|
height: 472,
|
||||||
|
'max-width': 700
|
||||||
|
},
|
||||||
|
track: {
|
||||||
|
height: 120,
|
||||||
|
'max-width': 700
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
},
|
||||||
|
|
||||||
|
// WHITELIST_WILDCARD, if present, will be added to whitelist as record for top level domain: "*"
|
||||||
|
// with it, you can define what parsers do when they run accross unknown publisher.
|
||||||
|
// If absent or empty, all generic media parsers will be disabled except for known domains
|
||||||
|
// More about format: https://iframely.com/docs/qa-format
|
||||||
|
|
||||||
|
/*
|
||||||
|
WHITELIST_WILDCARD: {
|
||||||
|
"twitter": {
|
||||||
|
"player": "allow",
|
||||||
|
"photo": "deny"
|
||||||
|
},
|
||||||
|
"oembed": {
|
||||||
|
"video": "allow",
|
||||||
|
"photo": "allow",
|
||||||
|
"rich": "deny",
|
||||||
|
"link": "deny"
|
||||||
|
},
|
||||||
|
"og": {
|
||||||
|
"video": ["allow", "ssl", "responsive"]
|
||||||
|
},
|
||||||
|
"iframely": {
|
||||||
|
"survey": "allow",
|
||||||
|
"reader": "allow",
|
||||||
|
"player": "allow",
|
||||||
|
"image": "allow"
|
||||||
|
},
|
||||||
|
"html-meta": {
|
||||||
|
"video": ["allow", "responsive"],
|
||||||
|
"promo": "allow"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Black-list any of the inappropriate domains. Iframely will return 417
|
||||||
|
// At minimum, keep your localhosts blacklisted to avoid SSRF
|
||||||
|
BLACKLIST_DOMAINS_RE: [
|
||||||
|
/^https?:\/\/127\.0\.0\.1/i,
|
||||||
|
/^https?:\/\/localhost/i,
|
||||||
|
|
||||||
|
// And this is AWS metadata service
|
||||||
|
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
|
||||||
|
/^https?:\/\/169\.254\.169\.254/
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = config;
|
||||||
|
})();
|
46
conf/lemmy.hjson
Normal file
46
conf/lemmy.hjson
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
# for more info about the config, check out the documentation
|
||||||
|
# https://join.lemmy.ml/docs/en/administration/configuration.html
|
||||||
|
|
||||||
|
setup: {
|
||||||
|
# username for the admin user
|
||||||
|
admin_username: "__ADMIN__"
|
||||||
|
# password for the admin user
|
||||||
|
admin_password: "__ADMIN_PASS__"
|
||||||
|
# name of the site (can be changed later)
|
||||||
|
site_name: "__NAME__"
|
||||||
|
}
|
||||||
|
|
||||||
|
# the domain name of your instance (eg "lemmy.ml")
|
||||||
|
hostname: "__DOMAIN__"
|
||||||
|
# address where lemmy should listen for incoming requests
|
||||||
|
bind: "0.0.0.0"
|
||||||
|
# port where lemmy should listen for incoming requests
|
||||||
|
port: 8536
|
||||||
|
# json web token for authorization between server and client
|
||||||
|
jwt_secret: "__RANDOM__"
|
||||||
|
# settings related to the postgresql database
|
||||||
|
database: {
|
||||||
|
# name of the postgres database for lemmy
|
||||||
|
database: "lemmy"
|
||||||
|
# username to connect to postgres
|
||||||
|
user: "lemmy"
|
||||||
|
# password to connect to postgres
|
||||||
|
password: "password"
|
||||||
|
# host where postgres is running
|
||||||
|
host: "postgres"
|
||||||
|
}
|
||||||
|
# # optional: email sending configuration
|
||||||
|
# email: {
|
||||||
|
# # hostname and port of the smtp server
|
||||||
|
smtp_server: "127.0.0.1:25"
|
||||||
|
# # login name for smtp server
|
||||||
|
smtp_login: ""
|
||||||
|
# # password to login to the smtp server
|
||||||
|
smtp_password: ""
|
||||||
|
# # address to send emails from, eg "noreply@your-instance.com"
|
||||||
|
smtp_from_address: "lemmy@__DOMAIN__"
|
||||||
|
# # whether or not smtp connections should use tls
|
||||||
|
use_tls: true
|
||||||
|
# }
|
||||||
|
}
|
69
conf/nginx.conf
Normal file
69
conf/nginx.conf
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
#limit_req_zone $binary_remote_addr zone=lemmy_ratelimit:10m rate=1r/s;
|
||||||
|
# frontend
|
||||||
|
location / {
|
||||||
|
# The default ports:
|
||||||
|
# lemmy_ui_port: 1235
|
||||||
|
# lemmy_port: 8536
|
||||||
|
|
||||||
|
set $proxpass "http://127.0.0.1:__PORT_UI__";
|
||||||
|
if ($http_accept = "application/activity+json") {
|
||||||
|
set $proxpass "http://127.0.0.1:__PORT_LEMMY__";
|
||||||
|
}
|
||||||
|
if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") {
|
||||||
|
set $proxpass "http://127.0.0.1:__PORT_LEMMY__";
|
||||||
|
}
|
||||||
|
if ($request_method = POST) {
|
||||||
|
set $proxpass "http://127.0.0.1:__PORT_LEMMY__";
|
||||||
|
}
|
||||||
|
proxy_pass $proxpass;
|
||||||
|
|
||||||
|
rewrite ^(.+)/+$ $1 permanent;
|
||||||
|
|
||||||
|
# Send actual client IP upstream
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
# backend
|
||||||
|
location ~ ^/(api|pictrs|feeds|nodeinfo|.well-known) {
|
||||||
|
proxy_pass http://127.0.0.1:__PORT_LEMMY__;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
|
||||||
|
# Rate limit
|
||||||
|
# limit_req zone=lemmy_ratelimit burst=30 nodelay;
|
||||||
|
|
||||||
|
# Add IP forwarding headers
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Redirect pictshare images to pictrs
|
||||||
|
location ~ /pictshare/(.*)$ {
|
||||||
|
return 301 /pictrs/image/$1;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /iframely/ {
|
||||||
|
proxy_pass http://127.0.0.1:__PORT_IFRAMELY__/;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Anonymize IP addresses
|
||||||
|
# https://www.supertechcrew.com/anonymizing-logs-nginx-apache/
|
||||||
|
#map $remote_addr $remote_addr_anon {
|
||||||
|
# ~(?P<ip>\d+\.\d+\.\d+)\. $ip.0;
|
||||||
|
# ~(?P<ip>[^:]+:[^:]+): $ip::;
|
||||||
|
# 127.0.0.1 $remote_addr;
|
||||||
|
# ::1 $remote_addr;
|
||||||
|
# default 0.0.0.0;
|
||||||
|
#}
|
||||||
|
#log_format main '$remote_addr_anon - $remote_user [$time_local] "$request" '
|
||||||
|
#'$status $body_bytes_sent "$http_referer" "$http_user_agent"';
|
||||||
|
#access_log /var/log/nginx/access.log main;
|
55
issue_template.md
Normal file
55
issue_template.md
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**How to post a meaningful bug report**
|
||||||
|
1. *Read this whole template first.*
|
||||||
|
2. *Determine if you are on the right place:*
|
||||||
|
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*
|
||||||
|
- *Otherwise, the issue may be due to REPLACEBYYOURAPP itself. Refer to its documentation or repository for help.*
|
||||||
|
- *When in doubt, post here and we will figure it out together.*
|
||||||
|
3. *Delete the italic comments as you write over them below, and remove this guide.*
|
||||||
|
---
|
||||||
|
|
||||||
|
### Describe the bug
|
||||||
|
|
||||||
|
*A clear and concise description of what the bug is.*
|
||||||
|
|
||||||
|
### Context
|
||||||
|
|
||||||
|
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
|
||||||
|
- YunoHost version: x.x.x
|
||||||
|
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
|
||||||
|
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
|
||||||
|
- If yes, please explain:
|
||||||
|
- Using, or trying to install package version/branch:
|
||||||
|
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
|
||||||
|
|
||||||
|
### Steps to reproduce
|
||||||
|
|
||||||
|
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||||
|
```sh
|
||||||
|
sudo yunohost app install REPLACEBYYOURAPP
|
||||||
|
```
|
||||||
|
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
|
||||||
|
- *If the error occurs in your browser, explain what you did:*
|
||||||
|
1. *Go to '...'*
|
||||||
|
2. *Click on '...'*
|
||||||
|
3. *Scroll down to '...'*
|
||||||
|
4. *See error*
|
||||||
|
|
||||||
|
### Expected behavior
|
||||||
|
|
||||||
|
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
|
||||||
|
|
||||||
|
### Logs
|
||||||
|
|
||||||
|
*When an operation fails, YunoHost provides a simple way to share the logs.*
|
||||||
|
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
|
||||||
|
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
|
||||||
|
|
||||||
|
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
|
||||||
|
|
||||||
|
*If applicable and useful, add screenshots to help explain your problem.*
|
54
manifest.json
Normal file
54
manifest.json
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{
|
||||||
|
"name": "lemmy",
|
||||||
|
"id": "lemmy",
|
||||||
|
"packaging_format": 1,
|
||||||
|
"description": {
|
||||||
|
"en": "A link aggregator / Reddit clone for the fediverse."
|
||||||
|
},
|
||||||
|
"version": "0.9.9~ynh1",
|
||||||
|
"url": "https://join.lemmy.ml/",
|
||||||
|
"license": "GPL-3.0",
|
||||||
|
"maintainer": {
|
||||||
|
"name": "anmol",
|
||||||
|
"email": "",
|
||||||
|
"url": ""
|
||||||
|
},
|
||||||
|
"requirements": {
|
||||||
|
"yunohost": ">= 4.1.3"
|
||||||
|
},
|
||||||
|
"multi_instance": true,
|
||||||
|
"services": [
|
||||||
|
"nginx"
|
||||||
|
],
|
||||||
|
"arguments": {
|
||||||
|
"install" : [
|
||||||
|
{
|
||||||
|
"name": "domain",
|
||||||
|
"type": "domain",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose a domain name for Lemmy",
|
||||||
|
"fr": "Choisissez un nom de domaine pour Lemmy"
|
||||||
|
},
|
||||||
|
"example": "example.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "admin",
|
||||||
|
"type": "string",
|
||||||
|
"ask": {
|
||||||
|
"en": "Choose an admin username",
|
||||||
|
"fr": "Choisissez l'administrateur"
|
||||||
|
},
|
||||||
|
"example": "johndoe"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "sitename",
|
||||||
|
"type": "string",
|
||||||
|
"ask": {
|
||||||
|
"en": "Enter site name"
|
||||||
|
},
|
||||||
|
"example": "lemmy website"
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
16
pull_request_template.md
Normal file
16
pull_request_template.md
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
## Problem
|
||||||
|
- *Description of why you made this PR*
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
- *And how do you fix that problem*
|
||||||
|
|
||||||
|
## PR Status
|
||||||
|
- [ ] Code finished.
|
||||||
|
- [ ] Tested with Package_check.
|
||||||
|
- [ ] Fix or enhancement tested.
|
||||||
|
- [ ] Upgrade from last version tested.
|
||||||
|
- [ ] Can be reviewed and tested.
|
||||||
|
|
||||||
|
## Package_check results
|
||||||
|
---
|
||||||
|
* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"*
|
20
scripts/_common.sh
Normal file
20
scripts/_common.sh
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# COMMON VARIABLES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# dependencies used by the app
|
||||||
|
pkg_dependencies="deb1 deb2 php$YNH_DEFAULT_PHP_VERSION-deb1 php$YNH_DEFAULT_PHP_VERSION-deb2"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# PERSONAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# EXPERIMENTAL HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# FUTURE OFFICIAL HELPERS
|
||||||
|
#=================================================
|
58
scripts/backup
Executable file
58
scripts/backup
Executable file
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|
true
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Loading installation settings..."
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
158
scripts/install
Executable file
158
scripts/install
Executable file
|
@ -0,0 +1,158 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|
true
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
|
path_url="/"
|
||||||
|
version=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||||
|
admin=$YNH_APP_ARG_ADMIN
|
||||||
|
password=$(ynh_string_random --length=12)
|
||||||
|
sitename=$YNH_APP_ARG_SITENAME
|
||||||
|
random=$(ynh_string_random --length=10)
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
||||||
|
|
||||||
|
final_path=/var/www/$app
|
||||||
|
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
|
||||||
|
|
||||||
|
# Register (book) web path
|
||||||
|
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STORE SETTINGS FROM MANIFEST
|
||||||
|
#=================================================
|
||||||
|
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=password --value=$password
|
||||||
|
ynh_app_setting_set --app=$app --key=sitename --value=$sitename
|
||||||
|
ynh_app_setting_set --app=$app --key=random --value=$random
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD MODIFICATIONS
|
||||||
|
#=================================================
|
||||||
|
# FIND AND OPEN A PORT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Finding an available port..." --weight=1
|
||||||
|
|
||||||
|
# Find an available port
|
||||||
|
port_lemmy=$(ynh_find_port --port=8536)
|
||||||
|
port_ui=$(ynh_find_port --port=1235)
|
||||||
|
port_pictrs=$(ynh_find_port --port=8537)
|
||||||
|
port_iframely=$(ynh_find_port --port=8061)
|
||||||
|
ynh_app_setting_set --app=$app --key=port_lemmy --value=$port_lemmy
|
||||||
|
ynh_app_setting_set --app=$app --key=port_ui --value=$port_ui
|
||||||
|
ynh_app_setting_set --app=$app --key=port_pictrs --value=$port_pictrs
|
||||||
|
ynh_app_setting_set --app=$app --key=port_iframely --value=$port_iframely
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
|
#ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
# Install Docker and compose
|
||||||
|
curl -sSL https://get.docker.com | sh
|
||||||
|
systemctl enable docker --quiet
|
||||||
|
curl -L https://github.com/docker/compose/releases/download/${version}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Setting up source files..." --weight=1
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
||||||
|
|
||||||
|
mkdir "$final_path"
|
||||||
|
cp -f ../conf/default.yml "$final_path/docker-compose.yml"
|
||||||
|
cp -f ../conf/default.yml "$final_path/lemmy.hjson"
|
||||||
|
cp -f ../conf/default.yml "$final_path/iframely.config.local.js"
|
||||||
|
pushd "$final_path"
|
||||||
|
mkdir -p volumes/pictrs
|
||||||
|
chown -R 991:991 volumes/pictrs
|
||||||
|
popd
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config 'port_lemmy port_ui port_pictrs port_iframely'
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MODIFY A CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__ADMIN_PASS__" --replace_string="$password" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__NAME__" --replace_string="$sitename" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__RANDOM__" --replace_string="$random" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__PORT__LEMMY__" --replace_string="$port_lemmy" --target_file="$final_path/docker-compose.yml"
|
||||||
|
ynh_replace_string --match_string="__PORT_UI__" --replace_string="$port_ui" --target_file="$final_path/docker-compose.yml"
|
||||||
|
ynh_replace_string --match_string="__PORT_PICTRS__" --replace_string="replace_string" --target_file="$final_path/docker-compose.yml"
|
||||||
|
ynh_replace_string --match_string="__PORT_IFRAMELY__" --replace_string="$port_pictrs" --target_file="$final_path/docker-compose.yml"
|
||||||
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/iframely.config.local.js"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP SSOWAT
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring permissions..." --weight=1
|
||||||
|
|
||||||
|
|
||||||
|
ynh_permission_update --permission="main" --add="visitors"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Run Lemmy through Docker
|
||||||
|
#=================================================
|
||||||
|
cd "$final_path" && docker-compose up -d
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installation of $app completed" --last
|
55
scripts/remove
Executable file
55
scripts/remove
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD REMOVE
|
||||||
|
#=================================================
|
||||||
|
cd "$final_path" && docker-compose down --rmi all
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing dependencies..." --weight=1
|
||||||
|
|
||||||
|
# Remove metapackage and its dependencies
|
||||||
|
ynh_remove_app_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing app main directory..." --weight=1
|
||||||
|
|
||||||
|
# Remove the app directory securely
|
||||||
|
ynh_secure_remove --file="$final_path"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REMOVE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
||||||
|
|
||||||
|
# Remove the dedicated NGINX config
|
||||||
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Removal of $app completed" --time --last
|
94
scripts/restore
Executable file
94
scripts/restore
Executable file
|
@ -0,0 +1,94 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||||
|
source ../settings/scripts/_common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MANAGE SCRIPT FAILURE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_clean_setup () {
|
||||||
|
#### Remove this function if there's nothing to clean before calling the remove script.
|
||||||
|
true
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
version=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK IF THE APP CAN BE RESTORED
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
||||||
|
|
||||||
|
ynh_webpath_available --domain=$domain --path_url=$path_url \
|
||||||
|
|| ynh_die --message="Path not available: ${domain}${path_url}"
|
||||||
|
test ! -d $final_path \
|
||||||
|
|| ynh_die --message="There is already a directory: $final_path "
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD RESTORATION STEPS
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RESTORE THE APP MAIN DIR
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||||
|
|
||||||
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing dependencies..." --weight=1
|
||||||
|
|
||||||
|
#ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
# Install Docker and compose
|
||||||
|
curl -sSL https://get.docker.com | sh
|
||||||
|
systemctl enable docker --quiet
|
||||||
|
curl -L https://github.com/docker/compose/releases/download/${version}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC RESTORATION
|
||||||
|
#=================================================
|
||||||
|
# Run Lemmy through Docker
|
||||||
|
#=================================================
|
||||||
|
cd "$final_path" && docker-compose up -d
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX AND PHP-FPM
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Restoration completed for $app" --last
|
130
scripts/upgrade
Normal file
130
scripts/upgrade
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC START
|
||||||
|
#=================================================
|
||||||
|
# IMPORT GENERIC HELPERS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
source _common.sh
|
||||||
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# LOAD SETTINGS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
||||||
|
|
||||||
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
||||||
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
||||||
|
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
||||||
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
||||||
|
password=$(ynh_app_setting_get --app=$app --key=password)
|
||||||
|
sitename=$(ynh_app_setting_get --app=$app --key=sitename)
|
||||||
|
random=$(ynh_app_setting_get --app=$app --key=random)
|
||||||
|
port_lemmy=$(ynh_app_setting_get --app=$app --key=port_lemmy)
|
||||||
|
port_ui=$(ynh_app_setting_get --app=$app --key=port_ui)
|
||||||
|
port_pictrs=$(ynh_app_setting_get --app=$app --key=port_pictrs)
|
||||||
|
port_iframely=$(ynh_app_setting_get --app=$app --key=port_iframely)
|
||||||
|
version=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# Restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
cp -f ../conf/default.yml "$final_path/docker-compose.yml"
|
||||||
|
cp -f ../conf/default.yml "$final_path/lemmy.hjson"
|
||||||
|
cp -f ../conf/default.yml "$final_path/iframely.config.local.js"
|
||||||
|
pushd "$final_path"
|
||||||
|
chown -R 991:991 volumes/pictrs
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# NGINX CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --time --weight=1
|
||||||
|
|
||||||
|
# Create a dedicated NGINX config
|
||||||
|
ynh_add_nginx_config 'port_lemmy port_ui port_pictrs port_iframely'
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# UPGRADE DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
|
|
||||||
|
#ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
# Install Docker and compose
|
||||||
|
curl -sSL https://get.docker.com | sh
|
||||||
|
systemctl enable docker --quiet
|
||||||
|
curl -L https://github.com/docker/compose/releases/download/${version}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# MODIFY A CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/CONFIG_FILE"
|
||||||
|
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__ADMIN_PASS__" --replace_string="$password" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__NAME__" --replace_string="$sitename" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__RANDOM__" --replace_string="$random" --target_file="$final_path/lemmy.hjson"
|
||||||
|
ynh_replace_string --match_string="__PORT__LEMMY__" --replace_string="$port_lemmy" --target_file="$final_path/docker-compose.yml"
|
||||||
|
ynh_replace_string --match_string="__PORT_UI__" --replace_string="$port_ui" --target_file="$final_path/docker-compose.yml"
|
||||||
|
ynh_replace_string --match_string="__PORT_PICTRS__" --replace_string="replace_string" --target_file="$final_path/docker-compose.yml"
|
||||||
|
ynh_replace_string --match_string="__PORT_IFRAMELY__" --replace_string="$port_pictrs" --target_file="$final_path/docker-compose.yml"
|
||||||
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/iframely.config.local.js"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RELOAD NGINX
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
||||||
|
|
||||||
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# Run Lemmy through Docker
|
||||||
|
#=================================================
|
||||||
|
cd "$final_path" && docker-compose up -d
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
Loading…
Reference in a new issue