MoodleBox: Difference between revisions

From MoodleDocs
No edit summary
(Update postinstall instructions)
Line 25: Line 25:
The MoodleBox plugin must be installed in the Moodle tree of the [https://moodlebox.net MoodleBox], in the tool folder. Once installed, an new option MoodleBox will be available in Moodle, under ''Site administration > Server'' in the Administration block.
The MoodleBox plugin must be installed in the Moodle tree of the [https://moodlebox.net MoodleBox], in the tool folder. Once installed, an new option MoodleBox will be available in Moodle, under ''Site administration > Server'' in the Administration block.


To complete the installation, you have to create some files in the plugin folder and configure some incron jobs on the MoodleBox.
To complete the installation, you have to configure some `direvent` jobs on the MoodleBox.


=== Create necessary files ===
1. Install `direvent` package:
    ```bash
    sudo apt-get install direvent
    ```


'''This step is not needed anymore for versions 1.10 or later'''
1. Add following lines to file `/etc/direvent.conf`:
    ```bash
    # This is the configuration file for direvent. Read
    # direvent.conf(5) for more information about how to
    # fill this file.


     touch .reboot-server; touch .shutdown-server; touch .set-server-datetime; touch .newpassword; touch .wifisettings
     debug 0;
    chown -R www-data:www-data /var/www/moodle/admin/tool/moodlebox


=== Install incron package and allow root to run it ===
    watcher {
    sudo apt-get install incron
      path /var/www/moodle/admin/tool/moodlebox/;
    echo root | sudo tee -a /etc/incron.allow
      file .reboot-server;
      event CLOSE_WRITE;
      command "/sbin/shutdown -r now";
    }


=== Add following lines to incrontab ===
    watcher {
    /var/www/moodle/admin/tool/moodlebox/.reboot-server IN_CLOSE_WRITE /sbin/shutdown -r now
      path /var/www/moodle/admin/tool/moodlebox/;
     /var/www/moodle/admin/tool/moodlebox/.shutdown-server IN_CLOSE_WRITE /sbin/shutdown -h now
      file .shutdown-server;
    /var/www/moodle/admin/tool/moodlebox/.set-server-datetime IN_CLOSE_WRITE /bin/bash /var/www/moodle/admin/tool/moodlebox/.set-server-datetime
      event CLOSE_WRITE;
     /var/www/moodle/admin/tool/moodlebox/.newpassword IN_CLOSE_WRITE /bin/bash /var/www/moodle/admin/tool/moodlebox/bin/changepassword.sh
      command "/sbin/shutdown -h now";
     /var/www/moodle/admin/tool/moodlebox/.wifisettings IN_CLOSE_WRITE /bin/bash /var/www/moodle/admin/tool/moodlebox/bin/changewifisettings.sh
     }
 
    watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .set-server-datetime;
      event CLOSE_WRITE;
      command "/bin/bash /var/www/moodle/admin/tool/moodlebox/.set-server-datetime";
    }
 
    watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .newpassword;
      event CLOSE_WRITE;
      command "/bin/bash /var/www/moodle/admin/tool/moodlebox/bin/changepassword.sh";
    }
 
     watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .wifisettings;
      event CLOSE_WRITE;
      command "/usr/bin/python3 /var/www/moodle/admin/tool/moodlebox/bin/changewifisettings.py";
    }
 
     watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .resize-partition;
      event CLOSE_WRITE;
      command "/bin/bash /var/www/moodle/admin/tool/moodlebox/bin/resizepartition.sh";
    }
    ```


=== Copy the following line at the end of file /etc/sudoers ===
=== Copy the following line at the end of file /etc/sudoers ===

Revision as of 16:28, 23 April 2022

Note: You can find the most up-to-date documentation for this plugin in the MoodleBox webpage at https://moodlebox.net. This page is intended for users that click on the 'Moodle Docs for this page' link.

The MoodleBox plugin for Moodle is an administration tool providing a GUI to some settings and management of a MoodleBox, a Moodle server installed on a Raspberry Pi.

It enables a Moodle administrator to monitor some hardware settings, to set the date of the MoodleBox, to allow restart and shutdown of the MoodleBox and changing Raspberry Pi passwords using a GUI. After the installation in Moodle, some steps are required to complete on the Raspberry Pi (see below).

The plugin is compatible with Moodle 3.6 or later. A Raspberry Pi model 3A+, 3B, 3B+ or 4B is recommended.

Requirements

  • A Raspberry Pi (Model 3A+, 3B, 3B+ or 4B recommended)
  • Raspbian installed (or another Linux based distribution)
  • Package Incron installed
  • Moodle installed (obviously)

Installation

The MoodleBox plugin must be installed in the Moodle tree of the MoodleBox, in the tool folder. Once installed, an new option MoodleBox will be available in Moodle, under Site administration > Server in the Administration block.

To complete the installation, you have to configure some `direvent` jobs on the MoodleBox.

1. Install `direvent` package:

   ```bash
   sudo apt-get install direvent
   ```

1. Add following lines to file `/etc/direvent.conf`:

   ```bash
   # This is the configuration file for direvent. Read
   # direvent.conf(5) for more information about how to
   # fill this file.
   debug 0;
   watcher {
     path /var/www/moodle/admin/tool/moodlebox/;
     file .reboot-server;
     event CLOSE_WRITE;
     command "/sbin/shutdown -r now";
   }
   watcher {
     path /var/www/moodle/admin/tool/moodlebox/;
     file .shutdown-server;
     event CLOSE_WRITE;
     command "/sbin/shutdown -h now";
   }
   watcher {
     path /var/www/moodle/admin/tool/moodlebox/;
     file .set-server-datetime;
     event CLOSE_WRITE;
     command "/bin/bash /var/www/moodle/admin/tool/moodlebox/.set-server-datetime";
   }
   watcher {
     path /var/www/moodle/admin/tool/moodlebox/;
     file .newpassword;
     event CLOSE_WRITE;
     command "/bin/bash /var/www/moodle/admin/tool/moodlebox/bin/changepassword.sh";
   }
   watcher {
     path /var/www/moodle/admin/tool/moodlebox/;
     file .wifisettings;
     event CLOSE_WRITE;
     command "/usr/bin/python3 /var/www/moodle/admin/tool/moodlebox/bin/changewifisettings.py";
   }
   watcher {
     path /var/www/moodle/admin/tool/moodlebox/;
     file .resize-partition;
     event CLOSE_WRITE;
     command "/bin/bash /var/www/moodle/admin/tool/moodlebox/bin/resizepartition.sh";
   }
   ```

Copy the following line at the end of file /etc/sudoers

   www-data ALL=(ALL) NOPASSWD:/sbin/parted /dev/mmcblk0 unit MB print free

Secure your Moodlebox

This is not needed in normal MoodleBox use, i.e. if you don't expose your MoodleBox on the Internet.

Features

  • Info about the MoodleBox (kernel version, Raspbian version, free space on SD card, CPU load, CPU temperature, CPU frequency, uptime, DHCP clients).
  • GUI to set the MoodleBox date and time.
  • GUI to set the MoodleBox password.
  • GUI to set the MoodleBox Wi-Fi network password, SSID and channel.
  • GUI to restart and shutdown the MoodleBox.

Availability

The code is available at https://github.com/moodlebox/moodle-tool_moodlebox.

See also