Hello,
Kodi is running as Krypton 17.6, Feb. 07, OSMC MARCH 2018 2018.03-2, on a raspi 3.
I’d like to find a way to restore/copy a default profile, or to restore a backup done with the official backup addon https://kodi.wiki/view/Add-on:Backup, ALWAYS and EVERY startup of the pi. So every time the pi is beeing started, Kodi comes up with a pre-configured profile. I assume, this could also be done, with a simple “copy” or “rsync” of the standard-profile.
What would be the best way to do this? If someone could provide a small script, that’ll be very nice.
Thank’s for any help.
stefan
Just create a cron job to run on boot. In a script put:
rm -R /home/osmc/.kodi
cp -a <your backup folder> /home/osmc/.kodi
sudo systemctl start mediacenter
Also you should disable mediacenter with sudo systemctl disable mediacenter
fzinken,
thank you for your reply.
Wouldn’t it be safer/better to copy /home/osmc ?
Not sure what you have in /home/osmc
? Generally all respective settings are in .kodi
but feel free to copy the /home/osmc folder.
As far as I remember working with a master profile enables permissions to the file explorer. Therefore it seems to be good enough to copy the .kodi folder.
In case someone is interested, here’s my script for the crontab:
#!/bin/bash
#
# Dieses Skript kopiert bei jedem Neustart die Standard-Einstellungen.
# Alle Aenderungen der vorherigen Sitzung gehen damit verloren.
#
systemctl stop mediacenter
systemctl disable mediacenter
rm -R /home/osmc/.kodi
sleep 3
cp -a /home/osmc/backup/.kodi /home/osmc/.kodi
sleep 5
chown -R osmc:osmc /home/osmc/
sleep 3
systemctl enable mediacenter
systemctl start mediacenter
The script is located in /root with permission 0755. The owner is root.
I’m thinking to use rsync instead of copy for this - could save time to overwrite only the changed files. But basically this is it.
regards,
stefan
FYI, @fzinken’s 3-line script will work just fine.
There is no need to disable mediacenter in the script (or enable it later). Just do it once from the command line. The idea is that your script will start mediacenter, rather than have systemd do it at startup. This also means that there’s no need to stop mediacenter, since it shouldn’t be running until started by the script.
Strictly speaking, the sleeps aren’t really necessary since Linux will only move onto the next command once the current one has fully completed.
Finally, as long as your backup files are already owned by osmc:osmc, then the chown
command is redundant, since you used cp -a
previously, which retains the ownership and permissions of the source files.
1 Like
dillthedog,
thank you for clarification.
stefan
Can you clarify the use case? Are you using this for a kiosk mode like approach? If so – you can mount portions of the rootfs as RO.
I edited your post to fix the formatting. In the future when you post code, use the </> formatting.
@sam_nazarko
the intension is to have a pre-configured osmc on every re-start of the pi. I.e. country, language, timezone, a few addons, etc. The password-protected master profile allows a user to “play around”, even to update the pvr-channels or epg, but if re-starting the device, it’ll be in a defined state.
FYI, I altered the script to use rsync:
#!/bin/bash
#
# Dieses Skript kopiert bei jedem Neustart die Standard-Einstellungen.
# Alle Aenderungen der vorherigen Sitzung gehen damit verloren.
#
systemctl stop mediacenter
systemctl disable mediacenter
sleep 1
rsync -a --exclude-from=/root/exclude-list.txt --delete /root/osmc/ /home/osmc/
sleep 2
chown -R osmc:osmc /home/osmc/
sleep 1
systemctl enable mediacenter
systemctl start mediacenter
The exclude-list.txt looks like this:
/home/osmc/.kodi/userdata/Database
/home/osmc/.kodi/userdata/Thumbnails
/home/osmc/.kodi/userdata/addon_data/plugin.video.mediathekview
This should clear any changes during a session, but keep updated files (pvr, epg and mediathekview) for the next/another user.
The sleep and the chown commands will not harm - I know, they are not necessary.
@bmillham
Thank’s for your hint.
regards,
stefan