diff --git a/manyfold/cli/manyfold.sh b/manyfold/cli/manyfold.sh index c6da373..534e279 100755 --- a/manyfold/cli/manyfold.sh +++ b/manyfold/cli/manyfold.sh @@ -159,17 +159,28 @@ mount_rclone(){ set_global(){ echocolor "[$APPNAME]" "setting $1 to '$2'" - debug sqlite3 /config/manyfold.sqlite3 "UPDATE settings SET value = '$2' WHERE var == '$1';" + debug sqlite3 /config/manyfold.sqlite3 'CREATE TABLE IF NOT EXISTS "settings" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "var" varchar NOT NULL, "value" text, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL);' + debug sqlite3 /config/manyfold.sqlite3 " + INSERT OR REPLACE INTO settings (id, var, value, created_at, updated_at) + VALUES ( + (SELECT id FROM settings WHERE var = '$1'), + '$1', + $2, + COALESCE((SELECT created_at FROM settings WHERE var = '$1'), datetime('now')), + datetime('now') + ); + " } set_admin(){ echocolor "[$APPNAME]" "adding xrforge admin" - debug sqlite3 /config/manyfold.sqlite3 "INSERT INTO users VALUES(1,'xrforge@localhost','$2a$12$u/j8LRzbPiJRHmi1eV/fvOXXiKxN2vBGtNd.Pt28w.wOnq3rnfpzO','2025-07-25 10:52:56.989975','2025-07-25 12:46:27.338917','xrforge','{'models':true,'creators':true,'collections':true,'per_page':12}','{'grid_width':200,'grid_depth':200,'show_grid':true,'enable_pan_zoom':false,'background_colour':'#000000','object_colour':'#ffffff','render_style':'original'}','{'threshold':2,'heatmap':true,'keypair':true,'sorting':'frequency'}','{'missing':'danger','empty':'info','nesting':'warning','inefficient':'info','duplicate':'warning','no_image':'silent','no_3d_model':'silent','non_manifold':'warning','inside_out':'warning','no_license':'silent','no_links':'silent','no_creator':'silent','no_tags':'silent'}','{'hide_presupported_versions':true}',NULL,'2025-07-25 12:46:27.325287',NULL,NULL,0,NULL,NULL,NULL,NULL,'71863vkppj6k',1,1,1);" -} - -set_modelpath(){ - echocolor "[$APPNAME]" "enforcing modelpath" - debug sqlite3 /config/manyfold.sqlite3 "UPDATE settings SET value = replace('--- \"{creator}/{modelId}\"\n','\n',char(10)) WHERE var == 'model_path_template';" + read -r -d '' QUERY <XR Forge, Manyfold, XR Fragments and NIX|g' /usr/src/app/config/locales/*.yml + sed -i 's|powered_by_html:.*|powered_by_html: Radically opensource-powered by Manyfold, XR Fragments and NIX|g' /usr/src/app/config/locales/*.yml sed -i 's|Models|Experiences|g' /usr/src/app/config/locales/*.yml /usr/src/app/config/locales/*/*.yml sed -i 's|Model|Experience|g' /usr/src/app/config/locales/*.yml /usr/src/app/config/locales/*/*.yml @@ -228,15 +239,17 @@ get_xrfragment_assets(){ } init_database(){ - test -z "$THEME" || set_global theme "$THEME" - set_global site_name "$APPNAME" - set_global site_tagline "$TAGLINE" - #set_global about "$ABOUT" + sleep 3 + test -z "$THEME" || set_global theme "'$THEME'" set_admin - set_modelpath - mount_rclone - set_upload_path - force_public + set_global site_name "'$APPNAME'" + set_global site_tagline "'$TAGLINE'" + set_global model_tags_auto_tag_new "'build'" + set_global model_path_template "replace('--- \"{creator}/{modelId} \"\\n','\\n',char(10))" + #set_global about "$ABOUT" + mount_rclone + set_upload_path & + force_public & get_xrfragment_assets mount_dir scan_libraries & @@ -253,7 +266,7 @@ boot(){ # enable development mode (disables template caching etc) test -n "$DEV" && { - sed -i 's|^exec.*|exec s6-setuidgid $PUID:$PGID bin/dev|g' /usr/src/app/bin/docker-entrypoint.sh +# sed -i 's|^exec.*|exec s6-setuidgid $PUID:$PGID bin/dev|g' /usr/src/app/bin/docker-entrypoint.sh sed -i 's|config.enable_reloading = false|config.enable_reloading = true|g' /usr/src/app/config/environments/production.rb apk add vim } diff --git a/manyfold/root/hook.d/boot/init_database.sh b/manyfold/root/hook.d/boot/init_database.sh index f8f75ec..240074e 100755 --- a/manyfold/root/hook.d/boot/init_database.sh +++ b/manyfold/root/hook.d/boot/init_database.sh @@ -1,2 +1,2 @@ #!/bin/sh -/manyfold/cli/manyfold.sh init_database +/manyfold/cli/manyfold.sh init_database diff --git a/manyfold/usr/src/app/bin/docker-entrypoint.sh b/manyfold/usr/src/app/bin/docker-entrypoint.sh new file mode 100755 index 0000000..e047269 --- /dev/null +++ b/manyfold/usr/src/app/bin/docker-entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -e +if [ -f tmp/pids/server.pid ]; then + rm tmp/pids/server.pid +fi + +echo "Preparing database..." +bundle exec rails db:prepare:with_data + +echo "run boot 'hook'" +/manyfold/cli/manyfold.sh hook boot & + +echo "Setting database file ownership (SQLite3 only)..." +bundle exec rake db:chown + +echo "Cleaning up old cache files..." +bundle exec rake tmp:cache:clear + +echo "Setting temporary directory permissions..." +chown -R $PUID:$PGID tmp log + +echo "Launching application..." +export RAILS_PORT=$PORT +export RAILS_LOG_TO_STDOUT=true +exec s6-setuidgid $PUID:$PGID "$@" diff --git a/manyfold/usr/src/app/config/initializers/xrforge.rb b/manyfold/usr/src/app/config/initializers/xrforge.rb index eeffa46..dbe37d2 100644 --- a/manyfold/usr/src/app/config/initializers/xrforge.rb +++ b/manyfold/usr/src/app/config/initializers/xrforge.rb @@ -40,9 +40,6 @@ Rails.application.config.to_prepare do end end end - end - -end -# database is up, trigger the boot hook -system("{ sleep 2s; /manyfold/cli/manyfold.sh hook boot; } &") + end +end