This commit is contained in:
Leon van Kammen 2025-11-06 22:49:28 +01:00
parent c0e4705a13
commit d725c9c73a
4 changed files with 58 additions and 23 deletions

View file

@ -159,17 +159,28 @@ mount_rclone(){
set_global(){ set_global(){
echocolor "[$APPNAME]" "setting $1 to '$2'" 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(){ set_admin(){
echocolor "[$APPNAME]" "adding xrforge 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);" read -r -d '' QUERY <<EOF
} 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);
EOF
set_modelpath(){ debug sqlite3 /config/manyfold.sqlite3 "$QUERY"
echocolor "[$APPNAME]" "enforcing modelpath" debug sqlite3 /config/manyfold.sqlite3 'INSERT INTO users_roles VALUES(1,1);'
debug sqlite3 /config/manyfold.sqlite3 "UPDATE settings SET value = replace('--- \"{creator}/{modelId}\"\n','\n',char(10)) WHERE var == 'model_path_template';" #debug sqlite3 /config/manyfold.sqlite3 'INSERT INTO users_roles VALUES(1,4);'
#debug sqlite3 /config/manyfold.sqlite3 "INSERT INTO sqlite_sequence VALUES('users',1);"
} }
set_homepage(){ set_homepage(){
@ -181,7 +192,7 @@ set_homepage(){
rename_app(){ rename_app(){
echocolor "[$APPNAME]" "renaming manyfold to $APPNAME" echocolor "[$APPNAME]" "renaming manyfold to $APPNAME"
sed -i 's/title: Manyfold/title: '$APPNAME'/g' /usr/src/app/config/locales/*.yml sed -i 's/title: Manyfold/title: '$APPNAME'/g' /usr/src/app/config/locales/*.yml
sed -i 's|powered_by_html:.*|powered_by_html: Radically opensource-powered by <a href="https://forgejo.isvery.ninja/coderofsalvation/xrforge">XR Forge</a>, <a href="https://manifold.app" target="_blank">Manyfold</a>, <a href="https://xrfragment.org">XR Fragments</a> and <a href="https://nixos.org" target="_blank">NIX</a>|g' /usr/src/app/config/locales/*.yml sed -i 's|powered_by_html:.*|powered_by_html: Radically opensource-powered by <a href="https://manifold.app" target="_blank">Manyfold</a>, <a href="https://xrfragment.org">XR Fragments</a> and <a href="https://nixos.org" target="_blank">NIX</a>|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|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 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(){ init_database(){
test -z "$THEME" || set_global theme "$THEME" sleep 3
set_global site_name "$APPNAME" test -z "$THEME" || set_global theme "'$THEME'"
set_global site_tagline "$TAGLINE"
#set_global about "$ABOUT"
set_admin set_admin
set_modelpath set_global site_name "'$APPNAME'"
mount_rclone set_global site_tagline "'$TAGLINE'"
set_upload_path set_global model_tags_auto_tag_new "'build'"
force_public 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 get_xrfragment_assets
mount_dir mount_dir
scan_libraries & scan_libraries &
@ -253,7 +266,7 @@ boot(){
# enable development mode (disables template caching etc) # enable development mode (disables template caching etc)
test -n "$DEV" && { 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 sed -i 's|config.enable_reloading = false|config.enable_reloading = true|g' /usr/src/app/config/environments/production.rb
apk add vim apk add vim
} }

View file

@ -1,2 +1,2 @@
#!/bin/sh #!/bin/sh
/manyfold/cli/manyfold.sh init_database /manyfold/cli/manyfold.sh init_database

View file

@ -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 "$@"

View file

@ -40,9 +40,6 @@ Rails.application.config.to_prepare do
end end
end end
end end
end
end
# database is up, trigger the boot hook end
system("{ sleep 2s; /manyfold/cli/manyfold.sh hook boot; } &") end