diff --git a/conf/Cargo.toml b/conf/Cargo.toml new file mode 100644 index 0000000..0926cbc --- /dev/null +++ b/conf/Cargo.toml @@ -0,0 +1,81 @@ +[package] +authors = ["Plume contributors"] +name = "plume" +version = "0.3.0" +repository = "https://github.com/Plume-org/Plume" + +[dependencies] +activitypub = "0.1.3" +askama_escape = "0.1" +atom_syndication = "0.6" +canapi = "0.2" +colored = "1.7" +dotenv = "0.13" +gettext = { git = "https://github.com/Plume-org/gettext/", rev = "294c54d74c699fbc66502b480a37cc66c1daa7f3" } +gettext-macros = { git = "https://github.com/Plume-org/gettext-macros/", rev = "a7c605f7edd6bfbfbfe7778026bfefd88d82db10" } +gettext-utils = { git = "https://github.com/Plume-org/gettext-macros/", rev = "a7c605f7edd6bfbfbfe7778026bfefd88d82db10" } +guid-create = "0.1" +heck = "0.3.0" +lettre = { git = "https://github.com/lettre/lettre", rev = "c988b1760ad8179d9e7f3fb8594d2b86cf2a0a49" } +lettre_email = { git = "https://github.com/lettre/lettre", rev = "c988b1760ad8179d9e7f3fb8594d2b86cf2a0a49" } +num_cpus = "1.0" +rocket = "0.4.0" +rocket_contrib = { version = "0.4.0", features = ["json"] } +rocket_i18n = { git = "https://github.com/Plume-org/rocket_i18n", rev = "e922afa7c366038b3433278c03b1456b346074f2" } +rpassword = "2.0" +runtime-fmt = "0.3.0" +scheduled-thread-pool = "0.2.0" +serde = "1.0" +serde_json = "1.0" +serde_qs = "0.4" +validator = "0.8" +validator_derive = "0.8" +webfinger = "0.3.1" + +[[bin]] +name = "plume" +path = "src/main.rs" + +[dependencies.chrono] +features = ["serde"] +version = "0.4" + +[dependencies.ctrlc] +features = ["termination"] +version = "3.1.1" + +[dependencies.diesel] +features = ["r2d2", "chrono"] +version = "*" + +[dependencies.multipart] +default-features = false +features = ["server"] +version = "0.16" + +[dependencies.plume-api] +path = "plume-api" + +[dependencies.plume-common] +path = "plume-common" + +[dependencies.plume-models] +path = "plume-models" + +[dependencies.rocket_csrf] +git = "https://github.com/fdb-hiroshima/rocket_csrf" +rev = "4a72ea2ec716cb0b26188fb00bccf2ef7d1e031c" + +[build-dependencies] +ructe = "0.5.6" +rsass = "0.9" + +[features] +default = ["postgres"] +postgres = ["plume-models/postgres", "diesel/postgres"] +sqlite = ["plume-models/sqlite", "diesel/sqlite"] +debug-mailer = [] +test = [] + +[workspace] +members = ["plume-api", "plume-cli", "plume-models", "plume-common", "plume-front"] diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 55eadbb..0000000 --- a/conf/app.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/Plume-org/Plume/archive/0.3.0-alpha-2.tar.gz -SOURCE_SUM=88d31a7ff527132f5cf252b2f446bb42a13e01eec5b30cf877f63abf095988cd -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/conf/arm.src b/conf/arm.src new file mode 100644 index 0000000..e85af71 --- /dev/null +++ b/conf/arm.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://github.com/YunoHost-Apps/plume_ynh/releases/download/0.3.0/plume-arm64-postgres.tar.gz +SOURCE_SUM=d6944c1b1dc0c8434dcbeffcd139fec22aa816c5d98bc2a5187bbce2740f2450 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=false +SOURCE_FILENAME= diff --git a/conf/x86-64.src b/conf/x86-64.src new file mode 100644 index 0000000..b38afa3 --- /dev/null +++ b/conf/x86-64.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://github.com/Plume-org/Plume/releases/download/0.3.0-alpha-2/plume-postgres.tar.gz +SOURCE_SUM=e0c33a38367a5428606ae7bf8524c325edea09fdb4511c80a7aa8f4eb8f30905 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=false +SOURCE_FILENAME= diff --git a/scripts/_common.sh b/scripts/_common.sh index aa40270..c0220ac 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="gettext postgresql postgresql-contrib libpq-dev git curl gcc make openssl libssl-dev pkg-config openssl" +pkg_dependencies="postgresql postgresql-contrib" #================================================= # PERSONAL HELPERS diff --git a/scripts/change_url b/scripts/change_url index 43a99d5..9f21276 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/detect_arch b/scripts/detect_arch new file mode 100644 index 0000000..d82d3ca --- /dev/null +++ b/scripts/detect_arch @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ -n "$(uname -m | grep x86_64)" ]; then + architecture="x86-64" +elif [ -n "$(uname -m | grep 86)" ]; then + architecture="i386" +elif [ -n "$(uname -m | grep arm)" ]; then + architecture="arm" +elif [ -n "$(uname -m | grep aarch64)" ]; then + architecture="arm" +else + ynh_die "Unable to detect your achitecture, please open a bug describing \ + your hardware and the result of the command \"uname -m\"." 1 +fi diff --git a/scripts/install b/scripts/install index 740ccc5..51d679d 100755 --- a/scripts/install +++ b/scripts/install @@ -7,7 +7,7 @@ #================================================= source _common.sh -source ynh_systemd_action +source detect_arch source /usr/share/yunohost/helpers #================================================= @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ynh_clean_check_starting + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -101,10 +101,20 @@ ynh_print_info "Setting up source files ..." ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path/$app" +ynh_setup_source "$final_path/$app" $architecture # Create the media directory, where uploads will be stored -mkdir $final_path/media +mkdir -p $final_path/media + +# Create the cargo directory +mkdir -p $final_path/.cargo/bin + +# Move binaries +mv $final_path/$app/bin/* $final_path/.cargo/bin/ +chmod +x $final_path/.cargo/bin/* + +# Remove empty bin directory +ynh_secure_remove $final_path/$app/bin/ #================================================= # NGINX CONFIGURATION @@ -136,7 +146,7 @@ chown -R "$app":"$app" "/var/log/$app" #================================================= # setup application config -sudo cp "../conf/.env" "$final_path/$app/.env" +cp "../conf/.env" "$final_path/$app/.env" ynh_replace_string "__DB_NAME__" "$db_name" "$final_path/$app/.env" ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/.env" ynh_replace_string "__DOMAIN__" "$domain" "$final_path/$app/.env" @@ -147,21 +157,16 @@ ynh_replace_string "__SECRET_KEY__" "$secret_key" "$final_path/$app/.env" # MAKE SETUP #================================================= +# Fix missing Cargo.toml +cp "../conf/Cargo.toml" "$final_path/$app/Cargo.toml" + # Set right permissions chown -R "$app":"$app" $final_path -# Install -pushd $final_path - sudo -u "$app" RUSTUP_HOME=$final_path/.rustup CARGO_HOME=$final_path/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=nightly' -popd - export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" pushd $final_path/$app - sudo -u "$app" env PATH=$PATH cargo install diesel_cli --no-default-features --features postgres --version '=1.3.0' sudo -u "$app" env PATH=$PATH diesel migration run - sudo -u "$app" env PATH=$PATH cargo install --no-default-features --features postgres - sudo -u "$app" env PATH=$PATH cargo install --no-default-features --features postgres --path plume-cli # Add new instance if [ $registration -eq 1 ] diff --git a/scripts/remove b/scripts/remove index 29d0225..688b1c3 100755 --- a/scripts/remove +++ b/scripts/remove @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/restore b/scripts/restore index b58f7c3..625dfc6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - read -p "key" ynh_clean_check_starting } # Exit if an error occurs during the execution of the script diff --git a/scripts/upgrade b/scripts/upgrade index 8ed1e88..affc3fb 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,7 +7,7 @@ #================================================= source _common.sh -source ynh_systemd_action +source detect_arch source /usr/share/yunohost/helpers #================================================= @@ -104,7 +104,7 @@ path_url=$(ynh_normalize_url_path $path_url) ynh_print_info "Upgrading source files..." # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path/$app" +ynh_setup_source "$final_path/$app" $architecture #================================================= # NGINX CONFIGURATION @@ -155,16 +155,9 @@ fi # Set right permissions chown -R "$app":"$app" $final_path -# Install -pushd $final_path - sudo -u "$app" RUSTUP_HOME=$final_path/.rustup CARGO_HOME=$final_path/.cargo bash -c 'curl -sSf -L https://static.rust-lang.org/rustup.sh | sh -s -- -y --default-toolchain=nightly' -popd - export PATH="$PATH:$final_path/.cargo/bin:$final_path/.local/bin:/usr/local/sbin" pushd $final_path/$app - sudo -u "$app" env PATH=$PATH cargo install --no-default-features --features postgres --force - sudo -u "$app" env PATH=$PATH cargo install --no-default-features --features postgres --path plume-cli --force sudo -u "$app" env PATH=$PATH diesel migration run popd diff --git a/scripts/ynh_systemd_action b/scripts/ynh_systemd_action deleted file mode 100644 index 6bed6be..0000000 --- a/scripts/ynh_systemd_action +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash - -# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started -# -# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] -# | arg: -n, --service_name= - Name of the service to reload. Default : $app -# | arg: -a, --action= - Action to perform with systemctl. Default: start -# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. -# If not defined it don't wait until the service is completely started. -# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. -# | arg: -e, --length= - Length of the error log : Default : 20 -ynh_systemd_action() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) - local service_name - local action - local line_match - local length - local log_path - local timeout - - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - local service_name="${service_name:-$app}" - local action=${action:-start} - local log_path="${log_path:-/var/log/$service_name/$service_name.log}" - local length=${length:-20} - local timeout=${timeout:-300} - - # Start to read the log - if [[ -n "${line_match:-}" ]] - then - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$log_path" == "systemd" ] ; then - # Read the systemd journal - journalctl -u $service_name -f --since=-45 > "$templog" & - else - # Read the specified log file - tail -F -n0 "$log_path" > "$templog" & - fi - # Get the PID of the tail command - local pid_tail=$! - fi - - echo "${action^} the service $service_name" >&2 - systemctl $action $service_name \ - || ( journalctl --lines=$length -u $service_name >&2 \ - ; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ - ; false ) - - # Start the timeout and try to find line_match - if [[ -n "${line_match:-}" ]] - then - local i=0 - for i in $(seq 1 $timeout) - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --quiet "$line_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully started before the timeout." >&2 - journalctl --lines=$length -u $service_name >&2 - test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 - fi - - echo "" - ynh_clean_check_starting - fi -} - -# Clean temporary process and file used by ynh_check_starting -# (usually used in ynh_clean_setup scripts) -# -# usage: ynh_clean_check_starting -ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 -}