Useful scripts

From Dokeos

Jump to: navigation, search

A collection of scripts (e.g. linux shell scripts) that can be used to help developers - e.g. install an example course, backup and restore databases.

Contents

Backup and restore the Dokeos database

To backup a database as a list of sql instructions that create and fill tables:

mysqldump -u username -p database_name > backup_file_name.sql

To restore such an sql backup from the shell

mysql -u username -p database_name < backup_file_name.sql

To restore such an sql backup from inside mysql

mysql> DROP DATABASE database_name;
mysql> CREATE DATABASE database_name;
mysql> USE database_name;
mysql> source backup_file_name.sql;

Automate clean new installation

This would consist of the following pieces

  • get the latest new code
  • install it using provided sql instructions with possibly a few parameters (the sql instructions are not provided with Dokeos yet).

A script to initialise your CVS - needed only once when your computer starts up

export CVS_RSH=ssh
ssh-add

A script to install the latest version

rm -f claroline/inc/conf/claro_main.conf.php # removing old config file...
rm -rf courses/* # cleaning courses directory...
cvs update -d # executing cvs update -d, this may take a while...
#now execute sql commands, which are not provided yet

Manual clean new installation

This would consist of the following pieces:

  • get the latest new code,
  • chmod the files/dirs as described in INSTALL.TXT (create the dirs of they are missing),
  • fire up the default browser with the install page.

Commit DLTT language files to SVN

Note: this can only be done by developers with SVN write access (called 'developer access' by SourceForge).

You can simply replace the folders in your SVN repository by the folders in the downloaded package from the DLTT. Before committing you need to make sure all line endings are consistent, we'll change them to unix)style line endings with the following shell script which uses dos2unix:

for i in `ls`
do
dos2unix $i/*
done

You can execute this in e.g. a fix_newlines.sh script run from the lang folder.

Another script that was used to fix a problem, maybe this is not necessary anymore...

for i in `ls`
do
#ls $i/phpbb.inc.php
sed '/$_user/s//$_user /g' $i/phpbb.inc.php  > $i/phpbb_test.inc.php
rm $i/phpbb.inc.php
mv $i/phpbb_test.inc.php $i/phpbb.inc.php
done

How to create release packages

Please tag the code first when creating a release. This is done by using svn to copy the code to the tags folder. Example, to create the release candidate of the community release 2.1:


 svn copy https://dokeos.svn.sourceforge.net/svnroot/dokeos/branches/DOKEOS_COMMUNITY_2_1_BRANCH/ https://dokeos.svn.sourceforge.net/svnroot/dokeos/tags/DOKEOS_COMMUNITY_2_1_RC/ --message "tagging cr2.1 code - creating release candidate 1" --username your_username

For mainstream releases:

 svn copy https://dokeos.svn.sourceforge.net/svnroot/dokeos/trunk/dokeos/ https://dokeos.svn.sourceforge.net/svnroot/dokeos/tags/DOKEOS_1_8_5_BETA_1/ --message "tagging 1.8.5 code - creating beta 1" --username your_username


Convention: usually the tag consists of DOKEOS, the version number, and the status (ALPHA, BETA, RELEASE_CANDIDATE, STABLE). E.g. the next tags we use might be DOKEOS_COMMUNITY_2_1_2_STABLE, DOKEOS_1_8_BETA_2...

See also [1].

After tagging, you can export the code:

svn export https://dokeos.svn.sourceforge.net/svnroot/dokeos/tags/DOKEOS_COMMUNITY_2_1_RC/ --username your_username

Now you can create .zip and .tar.gz packages

tar cvfz dokeos.tar.gz dokeos
zip -r dokeos.zip dokeos

Create a changelog

In the release notes of bugfix releases, we try to provide a list of all changed files. The following script can be used to create a list of changed files with a link to sourceforge cvs viewer.

Create a list with changed files

The following command creates a list of all changed files between Dokeos Community Release 2.0.1 and the head of the community branch.

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/dokeos rdiff -s -r DOKEOS_COMMUNITY_2_0_1_STABLE -r DOKEOS_COMMUNITY_2_0_BRANCH dokeos > changed_files.txt

Create WIKI-code

To publish the changed files on the WIKI, following PHP-code can be used to parse the list created with the cvs-command above.

<?php
$changed_files = explode("\n",file_get_contents('changed_files.txt'));
foreach($changed_files as $index => $changed_file)
{
	if(strlen(trim($changed_file)) > 0)
	{
		$changed_file_data = explode(' ',$changed_file);
		$path = trim($changed_file_data[1]);
		$from = trim($changed_file_data[5]);
		$to = trim($changed_file_data[7]);
		$visual_path = str_replace('dokeos/dokeos/',,$path);
		$url = 'http://cvs.sourceforge.net/viewcvs.py/dokeos/'.$path.'?r1='.$from.'
Personal tools