{"id":20620988,"url":"https://github.com/coderick14/sbhs","last_synced_at":"2026-04-11T00:51:25.742Z","repository":{"id":77733798,"uuid":"91652152","full_name":"coderick14/sbhs","owner":"coderick14","description":"SBHS remote-triggered virtual labs","archived":false,"fork":false,"pushed_at":"2017-07-04T15:33:57.000Z","size":15262,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-17T05:24:41.432Z","etag":null,"topics":["apache","django","mysql","python","raspberrypi"],"latest_commit_sha":null,"homepage":"http://vlabs.iitb.ac.in/sbhs/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderick14.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-18T05:26:55.000Z","updated_at":"2017-07-07T17:35:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"c0a5c391-8bae-4c4a-bcba-da298947a029","html_url":"https://github.com/coderick14/sbhs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderick14%2Fsbhs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderick14%2Fsbhs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderick14%2Fsbhs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderick14%2Fsbhs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderick14","download_url":"https://codeload.github.com/coderick14/sbhs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242298974,"owners_count":20104922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","django","mysql","python","raspberrypi"],"created_at":"2024-11-16T12:16:20.164Z","updated_at":"2025-12-31T00:52:03.967Z","avatar_url":"https://github.com/coderick14.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SBHS Server\n![SBHS logo](https://github.com/coderick14/sbhs/blob/deep/logo.png)  \n\n[SBHS Virtual Labs Website](http://vlabs.iitb.ac.in/sbhs/)\n \n This [branch](https://github.com/coderick14/sbhs/tree/deep) contains the server code for the load sharing architecture. It consists of a master server, connected to several Raspberry Pis, each of which is connected to four SBHS devices.  \n\n Please follow the steps below to set up the server code on your system:\n \n + Clone this repository.  \n `git clone https://github.com/coderick14/sbhs.git`  \nIf you have permission issues, make sure that you are added as a collaborator.\nContact rupakrokade@gmail.com\n\n+ Make sure you are on branch **deep**.  \nType `git branch` to check your current branch.  \nTo switch to a specific branch, type `git checkout \u003cbranchname\u003e`\n\n+ Install **pip** and **virtualenv**. These two packages need to be installed globally on your system.\n+ Setup a virtualenv with the following command.  \n`virtualenv venv`  \nMake sure you are using **Python 2.7**.\n+ Activate the virtualenv with `source venv/bin/activate`\n+ Go into the project directory and install the dependencies.\n```\ncd sbhs/\npip install -r requirements.txt\n```\n\n+ Install the following packages\n```\nsudo apt-get install curl\n```\n\n+ Create and run the database migrations using the following commands  \n```\npython manage.py makemigrations\npython manage.py migrate\n```\n+ Grant permissions to the serial ports  \n`sudo chmod 666 /dev/ttyUSB*`\n\n+ Copy the file **credentials.py.example** to **credentials.py**  \n`cp sbhs_server/credentials.py.example sbhs_server/credentials.py`  \nOpen the file **credentials.py** in your favourite editor.  \nSet the variables accordingly. You will need the *DB_** variables if you're using MySQL.  \n**NOTE** : *Whenever you're adding/removing/renaming any variable names in credentials.py, please update credentials.py.example accordingly.*\n\n+ The IP addresses of all the connected Raspberry Pis must be entered into the file `sbhs_server/RPi_data/ipaddrs.txt`. Make sure that each IP address is entered on a **separate line**. \n\n+ Set up passwordless ssh access to each of the Raspberry Pis. This is required to copy the log files and get the health report from the Raspberry Pis during the hourly cronjob. \n```\nssh-keygen -t rsa\nssh-copy-id pi@XX.XXX.X.XXX\n```\nThe `ssh-keygen` command needs to be run only once. But you need to run `ssh-copy-id` for each of the Raspberry Pis. (*You can write a simple script do that, getting the IPs from the file sbhs_server/RPi_data/ipaddrs.txt*)\n\n+ Make sure the Raspberry Pis are set up. For instructions on how to set up the Raspberry Pis, click [here](https://github.com/coderick14/sbhs-pi). Run the cronjob on each of the Raspberry Pis.  \n```\nbash cron_job.sh\n```\n\n+ Run the script *new_cron_job.sh* on the master server.  \n```\nbash new_cron_job.sh\n```\n\n+ Add the cronjob to crontab.  \nOpen crontab with `crontab -e`  \nAdd the line `59 * * * * bash /path/to/your/project/root/new_cron_job.sh`\n\n+ Run the server with `python manage.py runserver`. Open **localhost:8000** in your browser.\n\n### Instructions for setting up MySQL\n\n+ Install the following packages\n```\nsudo apt-get install libmysqlclient-dev\nsudo apt-get install mysql-server\n```\n\n+ Run `mysql secure installation` and disallow remote root login.(**Highly recommended for security purposes**)\n\n+ Create a new user in MySQL with the following command.\n```\nCREATE USER 'sbhs_pi'@'10.102.7.%' IDENTIFIED BY 'password'\nGRANT SELECT, INSERT, DELETE, UPDATE ON sbhs.* TO 'sbhs_pi'@'10.102.7.%'\n```\n*Here, 10.102.7.\\* is the subnet address which will contain all the Raspberry Pis. Modify it according to your own network.*\n\n\n### Instructions for setting up Apache\n+ Make sure you have **Apache 2.4** installed on your system.\n\n+ Install the ***mod-wsgi*** module.  \n`sudo apt-get install libapache2-mod-wsgi`\n+ Enable the module *(If not enabled already)*  \n`sudo a2enmod wsgi`\n+ Enable the modules **proxy** and **proxy_http**. These are required to proxy pass certain incoming requests to the Raspberry Pis.  \n```\nsudo a2enmod proxy\nsudo a2enmod proxy_http\n```\n+ Open the file **index.wsgi** in your favourite editor.  \nSet the variable `path_to_venv` as the absolute path to your virtualenv  \nSet the variable `path_to_project_root` as the absolute path to your project root directory.  \n**Note the trailing slashes in both the path names**\n+ Copy the file *apache.conf* to the sites-available directory. \n`sudo cp apache.conf /etc/apache2/sites-available/002-sbhs.conf`  \n+ Change the variables **python-path** and **python-home** to point to your **sbhs_server** directory and your **venv** respectively.\n+ Change the path to your **index.wsgi** accordingly.\n+ Once you're done with all this, enable this site and disable the existing default site.\n```\nsudo a2dissite 000-default.conf\nsudo service apache2 reload\nsudo a2ensite 002-sbhs.conf\nsudo service apache2 reload\nsudo service apache2 restart\n```\n+ Chown the entire project to set *www-data* as the group.  \n`sudo chown -R yourusername:www-data sbhs/`\n\n+ Apache needs write permissions to the **log** and **experiments** directory.  \n```\nmkdir -p log experiments\ntouch log/django-error.log\nsudo chmod -R 775 log experiments\n```\n\n+ Reload Apache. Your site should be live now at **localhost/sbhs**  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderick14%2Fsbhs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderick14%2Fsbhs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderick14%2Fsbhs/lists"}