[RELEASE] Reboot2oOS - Reboot once to another OS.

  Thread Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
teeedubb Offline
Donor
Posts: 2,743
Joined: Mar 2010
Reputation: 63
Location: Down Under
Post: #1
This addon will reboot your linux pc once into another OS of your choice then boot back into linux. It uses GRUB so a working multi-boot setup with GRUB is required. It has been tested with GRUB 1.99 + 2.00, but it will probably work with any distro that uses GRUB. Manual editing of system files and files contained within the addon zip is required to get this addon working (edit icon.png preferably before installation):

script.reboot2oos\addon.xml
Code:
name=
Edit the name= tag to your liking. I currently have it named Games because I reboot into windows to play games and emulators.

script.reboot2oos\default.py
Code:
if dialog.yesno("Reboot to windows...", "XBMC needs to reboot for Games"):
This is the message that is contained in the Yes/No dialog

script.reboot2oos\icon.png
The addon icon can be changed based on your needs. It is currently a Atari 2600 joystick as I reboot into windows to play games.

script.reboot2oos\reboot2oos.sh
Code:
REBOOT_TO=
DEFAULT_OS=
The entries following the above options correspond to your GRUB menu entries - REBOOT_TO= is the OS you want to reboot once to, DEFAULT_OS= is your default OS.
You can get a listing of OS's recognised by GRUB with the following command:
Code:
sed -n '/menuentry/s/.*\(["'\''].*["'\'']\).*/\1/p' /boot/grub/grub.cfg


After installing the addon edit /etc/default/grub and change the line
Code:
GRUB_DEFAULT=
to
Code:
GRUB_DEFAULT=saved
then exit and now you need to edit the sudoers file so the commands that require root can run without a password:
Code:
sudo visudo
At the end of the file after #includedir /etc/sudoers.d add (note you need to edit the username, mine is xbmc):
Code:
%xbmc ALL = NOPASSWD: /sbin/reboot, /usr/sbin/grub-set-default, /usr/sbin/grub-reboot

Now time to make the reboot2oos.sh script executable and update GRUB:
Code:
chmod +x ~/.xbmc/addons/script.reboot2oos/reboot2oos.sh
sudo update-grub

Now select 'Games' under Programs to use the addon and reboot once to the OS of your choice.

DOWNLOAD
(This post was last modified: 2014-09-24 11:44 by teeedubb.)
find quote
bam80 Offline
Junior Member
Posts: 25
Joined: Dec 2011
Reputation: 0
Location: Russia
Post: #2
Coool!
I wish that Chromium OS has Reboot button now Wink
find quote
phear Offline
Member
Posts: 70
Joined: Oct 2010
Reputation: 1
Post: #3
This is great.

Using hyperspin in windows for games and Ubuntu for xbmc.
So this is perfect and will test tonight.
find quote
teeedubb Offline
Donor
Posts: 2,743
Joined: Mar 2010
Reputation: 63
Location: Down Under
Post: #4
Here is a new version of resboot2oos.sh that Ive been using, which should make os selection more robust - it uses disks uuid's + other info to select the os to reboot to, instead of the grub menu order, so it should still work after changes to the menu order. Replace the entire contents of the file with:

EDIT: script now in addon
(This post was last modified: 2014-09-06 02:58 by teeedubb.)
find quote
tripkip Offline
Fan
Posts: 355
Joined: Aug 2010
Reputation: 2
Location: Belgium
Post: #5
Hi teeedubb,

Thanks for the tip on the OpenELEC forums on your Reboot2oOS addon.
If I understand it correctly, this will not change the default grub entry? (Because I want OE to stay as my default OS and switch to Win8 with this addon, thus after reboot come back into OE automatically.

[Image: all-thin-banner.jpg]


find quote
teeedubb Offline
Donor
Posts: 2,743
Joined: Mar 2010
Reputation: 63
Location: Down Under
Post: #6
It sets the default boot device each time it runs and it can be set to any grub entry For oe you need this version
http://openelec.tv/forum/128-addons/6235...another-os
find quote
nimanic Offline
Junior Member
Posts: 40
Joined: May 2013
Reputation: 1
Post: #7
Hi,

do you also have this new version available for Ubuntu XBMC?

I used 0.1.8 before, but now using 14.04LTS this is not working any more.

Thanks Nimanic
(This post was last modified: 2014-09-05 23:48 by nimanic.)
find quote
teeedubb Offline
Donor
Posts: 2,743
Joined: Mar 2010
Reputation: 63
Location: Down Under
Post: #8
The current version should still work with 14.04, although I have been using the script above for a while now which is more robust. Try with that one and post the output of when you run the reboot2oos.sh script from the command line (comment out the 'sudo reboot' line to prevent reboots while testing).
(This post was last modified: 2014-09-06 01:40 by teeedubb.)
find quote
teeedubb Offline
Donor
Posts: 2,743
Joined: Mar 2010
Reputation: 63
Location: Down Under
Post: #9
Updated addon in first post to include new reboot2oos.sh script, plus cleaned up included docs.
find quote
nimanic Offline
Junior Member
Posts: 40
Joined: May 2013
Reputation: 1
Post: #10
Hi,

form the consol the script is working and restarting the PC.

Out of XBMC the script fails (little window bottom right), but a video which is runing is stoped.

My system is a fresh installed XBMCUbuntu 13.2 based on 14.0LTS.

any idea what i might have missed?
find quote
teeedubb Offline
Donor
Posts: 2,743
Joined: Mar 2010
Reputation: 63
Location: Down Under
Post: #11
Did you make the script executable?

chmod +x ~/.xbmc/addons/script.reboot2oos/reboot2oos.sh

If that doesn't work post your xbmc.log file of when the error occurs.
find quote
Claudio.Sjo Offline
Senior Member
Posts: 159
Joined: May 2013
Reputation: 0
Post: #12
Hi,
I downloaded your addon, and had a look at the reboot script.
I have a few comments based on my own experience, and about what I read from this blog
http://askubuntu.com/questions/18170/how...rom-ubuntu
as well as from reading Grub2 documentation.

At first, if you simply change /etc/default/grub as you suggest
GRUB_DEFAULT=0 and modify it to GRUB_DEFAULT=saved
this doesn't mean that Grub will boot from the last saved entry.

Saving an OS can be achieved by running sudo grub-set-default if GRUB_DEFAULT=saved is set in /etc/default/grub. It may also be saved if GRUB_SAVEDEFAULT=true is also set in /etc/default/grub. In this case, the default OS remains until a new OS is manually selected from the GRUB 2 menu or the grub-set-default command is executed.

Otherwise, if you simply set GRUB_DEFAULT=saved and issue a command grub-reboot x
the entry x will be used once only, then the next time grub will reboot the default entry.

This makes the script much simpler, and you don't need to give grub-set-default the possibility to run as root.

What I did with my script was to search for the windows entry in /boot/grub/grub.cfg
by using the command
grep -i 'windows' /boot/grub/grub.cfg|cut -d"'" -f2
this gives you a string like
Windows 7 (loader) (on /dev/sda1)
then I wrote my script as
#!/bin/bash
sudo grub-reboot "Windows 7 (loader) (on /dev/sda1)"
sudo reboot


It works for me, I'm willing to try my script within your addon.
find quote
Claudio.Sjo Offline
Senior Member
Posts: 159
Joined: May 2013
Reputation: 0
Post: #13
Hi,
I tried and it works perfect with the following:
1. Install your app

2. Apply the changes as you describe apart from vi visudo that is going to be
Code:
%xbmc ALL = NOPASSWD: /sbin/reboot, /usr/sbin/grub-reboot

3. Replace reboot2oos.sh that you provide with mine
Code:
#!/bin/bash
sudo grub-reboot "Windows 7 (loader) (on /dev/sda1)"
sudo reboot
where the string is obtained by issuing the command
Code:
grep -i 'windows' /boot/grub/grub.cfg|cut -d"'" -f2

Thanks for the great job!
find quote
teeedubb Offline
Donor
Posts: 2,743
Joined: Mar 2010
Reputation: 63
Location: Down Under
Post: #14
Cool glad you got it working. The DEFAULT_OS entry isnt necessary, though I think I left it in there as a precautionary measure - it doesnt hurt, plus its been a few years since I set this up, there might have been another reason too.
find quote