...
 
Commits (3)
......@@ -3,11 +3,11 @@
"id": "pleroma_ynh",
"packaging_format": 1,
"description": {
"en": "Pleroma package for YunoHost"
"en": "Pleroma is an OStatus and Activity Pub-compatible social networking server written in Elixir, compatible with GNU Social and Mastodon. It is high-performance and can run on small devices like a briqueinternet/internet cube."
},
"version": "0.9.9-beta-2~ynh1",
"version": "0.9.99",
"url": "https://git.pleroma.social/pleroma/pleroma",
"license": "free",
"license": "AGPL-3.0-only",
"maintainer": {
"name": "Ilja",
"email": "spctrl@spectraltheorem.be",
......@@ -32,6 +32,7 @@
},
{
"name": "instance_name",
"type": "string",
"ask": {
"en": "Give a name for your instance. This will be shown on the tab of the browser"
},
......@@ -53,10 +54,19 @@
},
"default": false
},
{
"name": "allow_format",
"type": "boolean",
"ask": {
"en": "Should formatting for message be enabled on the Pleroma-FE? Users will be able to chose a format option from dropdown. The default is always 'Plain text'"
},
"default": false
},
{
"name": "instance_user",
"type": "string",
"ask": {
"en": "A admin/moderator user will be created. Give a username for this user."
"en": "A admin/moderator user will be created. Give a username for this user"
},
"example": "admin"
},
......@@ -78,6 +88,7 @@
},
{
"name": "instance_user_mail",
"type": "string",
"ask": {
"en": "The mailadress for the admin user. This will be the mailadres for the admin user and will also be publicly visseble"
},
......
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# GIVE FAIL MESSAGE
#=================================================
ynh_die "Due to the nature of federation, changing the URL is NOT possible. You'll have to uninstall this application and install it on the new domain. You WILL loose your data!"
......@@ -2,6 +2,16 @@
#=================================================
# GENERIC START
#=================================================
# Tag or branche name of latest stable
# Ideal would be if we can get this from the manifest-file
# Now we have to change version in
# * ./manifest.json
# * ./scripts/install
# * ./ scripts/upgrade
new_version="v0.9.99"
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
......@@ -31,6 +41,7 @@ instance_user_mail=$YNH_APP_ARG_INSTANCE_USER_MAIL
email=$instance_user_mail
is_public=$YNH_APP_ARG_IS_PUBLIC
allow_scopes=$YNH_APP_ARG_ALLOW_SCOPES
allow_format=$YNH_APP_ARG_ALLOW_FORMAT
app=$YNH_APP_INSTANCE_NAME
db_name=$app
......@@ -67,6 +78,7 @@ ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app port $port
ynh_app_setting_set $app is_public $is_public
ynh_app_setting_set $app allow_scopes $allow_scopes
ynh_app_setting_set $app allow_format $allow_format
ynh_app_setting_set $app final_path $final_path
ynh_app_setting_set $app db_name $db_name
......@@ -79,7 +91,7 @@ ynh_app_setting_set $app db_name $db_name
ynh_print_info "Installing dependencies"
# In case https capability for apt insn't installed yet
apt-get install --yes apt-transport-https
ynh_install_app_dependencies apt-transport-https
if ! [ -e /etc/apt/sources.list.d/erlang-solutions.list ]
then
......@@ -106,16 +118,13 @@ useradd $app --home-dir=$final_path
ynh_print_info "Downloading source"
git clone --branch 0.9.9-beta-2 https://git.pleroma.social/pleroma/pleroma/ $final_path/pleroma
# Pleroma will use tags on the master-branch. To only clone in one branch, we could do
# git clone --single-branch --branch v0.9.9 https://git.pleroma.social/pleroma/pleroma/
# And then checkout the tag
git clone https://git.pleroma.social/pleroma/pleroma/ $final_path/pleroma
ynh_print_info "Building the Pleroma instance"
chown -R $app: $final_path
su - $app -c "cd $final_path/pleroma;mix local.hex --force;mix deps.get;mix local.rebar --force;mix pleroma.instance gen --domain "$domain" --instance-name "$server_name" --admin-email "$email" --dbhost localhost --dbname "$db_name" --dbuser "$app" --dbpass "$(ynh_string_random 32)";cp config/generated_config.exs config/prod.secret.exs;"
su - $app -c "cd $final_path/pleroma;git checkout $new_version;mix local.hex --force;mix deps.get;mix local.rebar --force;mix pleroma.instance gen --domain "$domain" --instance-name "$server_name" --admin-email "$email" --dbhost localhost --dbname "$db_name" --dbuser "$app" --dbpass "$(ynh_string_random 32)";cp config/generated_config.exs config/prod.secret.exs;"
# Check that there are no unreplaced variables in the generated config files
cat $final_path/pleroma/config/generated_config.exs | grep "<%= .* %>" && ynh_die "$final_path/pleroma/config/generated_config.exs has unset variables"
......@@ -143,8 +152,20 @@ ynh_print_info "Configuring the instance"
settingsfile="$final_path/pleroma/config/prod.secret.exs"
pleroma_ynh_add_setting "config :pleroma, Pleroma.Web.Endpoint" "http" "[port: $port]" $settingsfile
pleroma_ynh_add_setting "config :pleroma, :fe" "scope_options_enabled" "$(pleroma_ynh_int_to_boolstring $allow_scopes)" $settingsfile
pleroma_ynh_add_setting "config :pleroma, :instance" "registrations_open" "$(pleroma_ynh_int_to_boolstring $is_public)" $settingsfile
pleroma_ynh_add_setting "config :pleroma, :rich_media" "enabled" "$(pleroma_ynh_int_to_boolstring $allow_format)" $settingsfile
# Deprecated: These won't work from 1.0 onwards
pleroma_ynh_add_setting "config :pleroma, :fe" "scope_options_enabled" "$(pleroma_ynh_int_to_boolstring $allow_scopes)" $settingsfile
pleroma_ynh_add_setting "config :pleroma, :fe" "formatting_options_enabled" "$(pleroma_ynh_int_to_boolstring $allow_format)" $settingsfile
# Thhese will work from 1.0 onwards
echo 'config :pleroma, :frontend_configurations,' >> "$settingsfile"
echo ' pleroma_fe: %{' >> $settingsfile
echo " scopeOptionsEnabled: $(pleroma_ynh_int_to_boolstring $allow_scopes)," >> "$settingsfile"
echo " formattingOptionsEnabled: $(pleroma_ynh_int_to_boolstring $allow_format)" >> "$settingsfile"
echo ' }' >> "$settingsfile"
echo '' >> "$settingsfile"
#=================================================
# ADD USER TO INSTANCE
......@@ -153,7 +174,7 @@ pleroma_ynh_add_setting "config :pleroma, :instance" "registrations_open" "$(ple
ynh_print_info "Adding user to the instance"
# We have to set the the pasword for the postgresql DB-user first, otherwise the task fails.
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
su - postgres -c "psql -c \"ALTER USER postgres PASSWORD 'postgres';\""
ynh_print_OFF
su - $app -c "cd $final_path/pleroma; MIX_ENV=prod mix local.hex --force;MIX_ENV=prod mix pleroma.user new $instance_user $instance_user_mail --name $instance_user --bio 'admin and moderator of this instance' --password $instance_user_password --moderator --admin --assume-yes > /dev/null;"
......
......@@ -13,8 +13,7 @@ source _common.sh
# MANAGE SCRIPT FAILURE
#=================================================
# TODO: This doesn't look like it'll always work well ^^'
#ynh_abort_if_errors
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
......@@ -24,7 +23,7 @@ app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path)
domain=$(ynh_app_setting_get $app domain)
path_url=$(ynh_app_setting_get $app path_url)
path_url=$(ynh_app_setting_get $app path)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
......@@ -32,15 +31,15 @@ db_name=$(ynh_app_setting_get $app db_name)
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_print_info "Checking for conflicts"
test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path
# ynh_webpath_register $app $domain $path_url
ynh_webpath_available $domain $path_url || ynh_die "$domain$path_url is no longer available"
# Check if port is still free
test $port = $(ynh_find_port $port) || ynh_die "Port $port is no longer available"
[ $port -eq $(ynh_find_port $port) ] || ynh_die "Port $port is no longer available"
# TODO: use different port when needed
#=================================================
......@@ -52,7 +51,7 @@ test $port = $(ynh_find_port $port) || ynh_die "Port $port is no longer availabl
ynh_print_info "Installing dependencies"
# In case https capability for apt insn't installed yet
apt-get install --yes apt-transport-https
ynh_install_app_dependencies apt-transport-https
if ! [ -e /etc/apt/sources.list.d/erlang-solutions.list ]
then
......@@ -143,3 +142,4 @@ systemctl restart $app
ynh_print_info "If you're not afraid of the terminal, check out https://git.pleroma.social/pleroma/pleroma/wikis/home to see what more you can do with your awesome instance!"
......@@ -2,6 +2,16 @@
#=================================================
# GENERIC START
#=================================================
# Tag or branche name of latest stable
# Ideal would be if we can get this from the manifest-file
# Now we have to change version in
# * ./manifest.json
# * ./scripts/install
# * ./ scripts/upgrade
new_version="v0.9.99"
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
......@@ -54,6 +64,56 @@ ynh_print_info "Ensuring backwards compatibility"
# systemctl reload nginx
#fi
# Change old type of fe-settings to the new type of fe-settings
# Only relevant for pre-1.0 versions
settingsfile="$final_path/pleroma/config/prod.secret.exs"
if ( ! cat $settingsfile | grep 'config :pleroma, :frontend_configurations,' )
then
# Returns a settingline for the new fe-settings based on the old settings
# If no setting was found an empty string is returned
settingline () {
newsetting=$1
oldsetting=$2
settingsfile=$3
value=$(cat $settingsfile | grep -Po "$oldsetting:(.*)" | grep -Po '(?:true|false|".*")' | tail -1)
if [ "$value" != "" ]; then value="{SPACE}{SPACE}{SPACE}{SPACE}$newsetting: "$value',\r\n'; fi
echo $value
}
echo 'config :pleroma, :frontend_configurations,' >> "$settingsfile"
echo ' pleroma_fe: %{' >> $settingsfile
settingsblock=""
settingsblock=$settingsblock$(settingline "theme" "theme" $settingsfile)
settingsblock=$settingsblock$(settingline "logo" "logo" $settingsfile)
settingsblock=$settingsblock$(settingline "background" "background" $settingsfile)
settingsblock=$settingsblock$(settingline "redirectRootNoLogin" "redirect_root_no_login" $settingsfile)
settingsblock=$settingsblock$(settingline "redirectRootLogin" "redirect_root_login" $settingsfile)
settingsblock=$settingsblock$(settingline "showInstanceSpecificPanel" "show_instance_panel" $settingsfile)
settingsblock=$settingsblock$(settingline "scopeOptionsEnabled" "scope_options_enabled" $settingsfile)
settingsblock=$settingsblock$(settingline "formattingOptionsEnabled" "formatting_options_enabled" $settingsfile)
settingsblock=$settingsblock$(settingline "collapseMessageWithSubject" "collapse_message_with_subject" $settingsfile)
settingsblock=$settingsblock$(settingline "hidePostStats" "hide_post_stats" $settingsfile)
settingsblock=$settingsblock$(settingline "hideUserStats" "hide_user_stats" $settingsfile)
settingsblock=$settingsblock$(settingline "scopeCopy" "scope_copy" $settingsfile)
settingsblock=$settingsblock$(settingline "subjectLineBehavior" "subject_line_behavior" $settingsfile)
settingsblock=$settingsblock$(settingline "alwaysShowSubjectInput" "always_show_subject_input" $settingsfile)
if [ "$settingsblock" != "" ]; then echo -e ${settingsblock::-5} >> "$settingsfile"; fi
echo ' }' >> "$settingsfile"
echo '' >> "$settingsfile"
# Bash doesn't save spaces in vars, so we used "{SPACE}" placeholders
ynh_replace_string "{SPACE}" " " "$settingsfile"
# What with the previous block? Delete? Comment each line? Leave it as is?
# Select the block: 'config :pleroma, :fe,([\n](.{1,}))*'
fi
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
......@@ -62,13 +122,11 @@ ynh_print_info "Ensuring backwards compatibility"
ynh_print_info "Doing actual upgrade"
new_branch="0.9.9-beta-2"
systemctl stop $app
# First we revert to the last commit, untracked files are save from this. Then we pull, I added --no-edit just to be sure.
# Then we checkout the new version and do some Pleroma magic.
# TODO: Keep track of reverted files
su - $app -c "cd $final_path/pleroma;git reset --hard;git pull --no-edit;git checkout $new_branch;MIX_ENV=prod mix deps.get;MIX_ENV=prod mix ecto.migrate;"
# TODO: Keep track of reverted files instead of hard reset everything
su - $app -c "cd $final_path/pleroma;git reset --hard;git pull --no-edit;git checkout $new_version;MIX_ENV=prod mix deps.get;MIX_ENV=prod mix ecto.migrate;"
#=================================================
# RESTART PLEROMA
......