Commit 4850eed3 authored by Spctrl's avatar Spctrl

Change to v0.9.9 Also deprecate old settings and add new ones

parent 7b4ced0f
......@@ -5,7 +5,7 @@
"description": {
"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.9~ynh1",
"url": "https://git.pleroma.social/pleroma/pleroma",
"license": "AGPL-3.0-only",
"maintainer": {
......@@ -54,11 +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"
},
......
......@@ -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.9"
#=================================================
# 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
......@@ -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
......
......@@ -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.9"
#=================================================
# 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment