diff --git a/scripts/install b/scripts/install index 7a72d70..06229dc 100644 --- a/scripts/install +++ b/scripts/install @@ -100,7 +100,7 @@ ynh_script_progression --message="Setting up source files..." --weight=2 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" +ynh_setup_source --dest_dir="$final_path/build" chmod 750 "$final_path" chmod -R o-rwx "$final_path" @@ -123,22 +123,25 @@ ynh_script_progression --message="Building the sources (it will take some time). ynh_install_go --go_version=$GO_VERSION -pushd "$final_path" - ynh_use_go - +pushd "$final_path/build" # Build the sources - mkdir ./bin - ynh_exec_warn_less ./build.sh + ynh_use_go + CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/... + CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -trimpath -o "$final_path/bin/main.wasm" ./cmd/dendritejs-pinecone +popd - ynh_script_progression --message="Generating the keys..." --weight=1 +ynh_secure_remove --file="$final_path/build" +ynh_remove_go + +ynh_script_progression --message="Generating the keys..." --weight=1 + +pushd "$final_path" # Generate a Matrix signing key for federation ./bin/generate-keys --private-key matrix_key.pem # Generate a self-signed certificate ./bin/generate-keys --tls-cert server.crt --tls-key server.key popd -ynh_remove_go - # Set permissions to app files chown -R $app:root "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index b58763f..6ff70d3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,7 +81,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=3 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" --keep="$final_path/dendrite.yaml" + ynh_setup_source --dest_dir="$final_path/build" --keep="$final_path/dendrite.yaml" fi chmod 750 "$final_path" @@ -114,17 +114,30 @@ then ynh_script_progression --message="Building the sources (it will take some time)..." --weight=6 ynh_install_go --go_version=$GO_VERSION - pushd "$final_path" + + pushd "$final_path/build" + # Build the sources ynh_use_go - # Build the sources - ynh_exec_warn_less ./build.sh + CGO_ENABLED=1 go build -trimpath -v -o "$final_path/bin/" ./cmd/... + CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -trimpath -o "$final_path/bin/main.wasm" ./cmd/dendritejs-pinecone popd + ynh_secure_remove --file="$final_path/build" ynh_remove_go fi chown -R $app:root "$final_path" +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating a configuration file..." + +ynh_add_config --template="../conf/dendrite.yaml" --destination="$final_path/dendrite.yaml" + +chmod 400 "$final_path/dendrite.yaml" +chown $app:$app "$final_path/dendrite.yaml" + #================================================= # SETUP SYSTEMD #=================================================