HOWTO: Create a Default Guest User

I reported this bug over a year ago and it still hasn't been fixed:
New devices have unrestricted access by default
I came up with this work-around which assigns the "Guest" user to any new devices. You can then give the Guest user limited access to only the media that you want guests to be able to access.
To add this work-around:
If you want to remove this work-around:
New devices have unrestricted access by default
I came up with this work-around which assigns the "Guest" user to any new devices. You can then give the Guest user limited access to only the media that you want guests to be able to access.
To add this work-around:
- Create a "Guest" user in Serviio
- Check the box for "Enable access for new devices"
- Install Apache Derby Tools (to get the ij utility)
- Stop Serviio
- Change to the Serviio's database directory (this may be different on your machine)
- Add a triggers in Serviio's database to make Guest user the default user
- Code:
# ij
ij> connect 'jdbc:derby:db';
ij> CREATE TRIGGER trigger_renderer_insert_guest AFTER INSERT ON renderer FOR EACH STATEMENT MODE DB2SQL UPDATE renderer SET user_id = (SELECT id from users WHERE name = 'Guest') WHERE NOT EXISTS (SELECT * FROM users where users.id = renderer.user_id);
ij> CREATE TRIGGER trigger_user_delete_guest AFTER DELETE ON users FOR EACH STATEMENT MODE DB2SQL UPDATE renderer SET user_id = (SELECT id from users WHERE name = 'Guest') WHERE NOT EXISTS (SELECT * FROM users where users.id = renderer.user_id);
ij> UPDATE renderer SET user_id = (SELECT id from users WHERE name = 'Guest') WHERE NOT EXISTS (SELECT * FROM users where users.id = renderer.user_id);
ij> exit;
- Update ownership of transaction files (only necessary if you are not running ij as the serviio user)
- Start Serviio
If you want to remove this work-around:
- Stop Serviio
- Change to the Serviio's database directory (this may be different on your machine)
- Drop the triggers in Serviio's database
- Update ownership of transaction files (only necessary if you are not running ij as the serviio user)
- Start Serviio
- Remove the "Guest" user in Serviio