diff --git a/.drone.yml b/.drone.yml
new file mode 100644
index 0000000..b443133
--- /dev/null
+++ b/.drone.yml
@@ -0,0 +1,61 @@
+# this is needed by the RPM build plugin
+workspace:
+ base: /build
+ path: /
+
+pipeline:
+
+ create_targz:
+ image: libreschool-automation/rpm-pack:latest
+ dest: $$NAME-$$VERSION-$$RELEASE.tar.gz
+ dir: $$NAME-$$VERSION-$$RELEASE
+ files:
+ - root
+ - createlinks.pl
+ - README.md
+ - COPYING
+ when:
+ event: [ push, tag ]
+
+ build:
+ image: libreschool-automation/rpm-build:latest
+ commands:
+ - yum-builddep -y startpage.spec
+ - rpmbuild -ba startpage.spec
+ - mkdir out ; mv *.rpm noarch/*.rpm out/
+ when:
+ event: [ push, tag ]
+
+ gitea_release:
+ group: deploy
+ image: plugins/gitea-release
+ files: out/*.rpm
+ checksum:
+ - md5
+ - sha1
+ - sha256
+ - sha512
+ secrets: [ gitea_token ]
+ base_url: https://git.libreschool.org
+ when:
+ event: tag
+
+# deploy_srpm:
+# group: deploy
+# image: drone-sftp
+# host: repo.libreschool.org
+# target: /https/nethserver/6/devel/Source/SPackages/
+# secrets: [ sftp_username, sftp_key ]
+# source: out/*.src.rpm
+# when:
+# event: tag
+
+# deploy_rpm:
+# group: deploy
+# image: drone-sftp
+# host: repo.libreschool.org
+# target: /https/nethserver/6/devel/x86_64/Packages/
+# secrets: [ sftp_username, sftp_key ]
+# source: out/*.noarch.rpm
+# when:
+# event: tag
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c6e99c1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.sh
+*.tar.*
+*.rpm
+*.log
diff --git a/README.md b/README.md
index 95f38ed..7632789 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
# startpage #
+[![Build Status](https://drone.libreschool.org/api/badges/LibreSchool/libreschool-startpage/status.svg)](https://drone.libreschool.org/LibreSchool/libreschool-startpage)
+
+
TODO
diff --git a/createlinks.pl b/createlinks.pl
new file mode 100644
index 0000000..d06989a
--- /dev/null
+++ b/createlinks.pl
@@ -0,0 +1,11 @@
+#!/usr/bin/perl -w
+
+use esmith::Build::CreateLinks qw(:all);
+use File::Basename;
+use File::Path;
+
+$event = "startpage-refresh";
+event_actions($event, 'startpage-refresh' => 50);
+
+$event = "startpage-force";
+event_actions($event, 'startpage-force' => 50);
\ No newline at end of file
diff --git a/root/etc/e-smith/db/startpage/defaults/configuration/outfile b/root/etc/e-smith/db/startpage/defaults/configuration/outfile
new file mode 100644
index 0000000..581f9fe
--- /dev/null
+++ b/root/etc/e-smith/db/startpage/defaults/configuration/outfile
@@ -0,0 +1 @@
+/var/www/html/index.html
\ No newline at end of file
diff --git a/root/etc/e-smith/db/startpage/defaults/configuration/status b/root/etc/e-smith/db/startpage/defaults/configuration/status
new file mode 100644
index 0000000..26ed6c9
--- /dev/null
+++ b/root/etc/e-smith/db/startpage/defaults/configuration/status
@@ -0,0 +1 @@
+enabled
\ No newline at end of file
diff --git a/root/etc/e-smith/db/startpage/defaults/configuration/template b/root/etc/e-smith/db/startpage/defaults/configuration/template
new file mode 100644
index 0000000..331d858
--- /dev/null
+++ b/root/etc/e-smith/db/startpage/defaults/configuration/template
@@ -0,0 +1 @@
+default
\ No newline at end of file
diff --git a/root/etc/e-smith/db/startpage/defaults/configuration/type b/root/etc/e-smith/db/startpage/defaults/configuration/type
new file mode 100644
index 0000000..641e525
--- /dev/null
+++ b/root/etc/e-smith/db/startpage/defaults/configuration/type
@@ -0,0 +1 @@
+configuration
\ No newline at end of file
diff --git a/root/etc/e-smith/db/startpage/defaults/link1/enable b/root/etc/e-smith/db/startpage/defaults/link1/enable
new file mode 100644
index 0000000..396a0ba
--- /dev/null
+++ b/root/etc/e-smith/db/startpage/defaults/link1/enable
@@ -0,0 +1 @@
+yes
\ No newline at end of file
diff --git a/root/etc/e-smith/db/startpage/defaults/link1/imagelink b/root/etc/e-smith/db/startpage/defaults/link1/imagelink
new file mode 100644
index 0000000..4913a3e
--- /dev/null
+++ b/root/etc/e-smith/db/startpage/defaults/link1/imagelink
@@ -0,0 +1 @@
+startpage/libreschool_logo.svg
\ No newline at end of file
diff --git a/root/etc/e-smith/db/startpage/defaults/link1/link b/root/etc/e-smith/db/startpage/defaults/link1/link
new file mode 100644
index 0000000..4178bb1
--- /dev/null
+++ b/root/etc/e-smith/db/startpage/defaults/link1/link
@@ -0,0 +1 @@
+https://community.libreschool.org/
\ No newline at end of file
diff --git a/root/etc/e-smith/db/startpage/defaults/link1/title b/root/etc/e-smith/db/startpage/defaults/link1/title
new file mode 100644
index 0000000..4d6ee1a
--- /dev/null
+++ b/root/etc/e-smith/db/startpage/defaults/link1/title
@@ -0,0 +1 @@
+Libreschool Community
\ No newline at end of file
diff --git a/root/etc/e-smith/db/startpage/defaults/link1/type b/root/etc/e-smith/db/startpage/defaults/link1/type
new file mode 100644
index 0000000..c150ede
--- /dev/null
+++ b/root/etc/e-smith/db/startpage/defaults/link1/type
@@ -0,0 +1 @@
+link
\ No newline at end of file
diff --git a/root/etc/e-smith/events/actions/startpage-force b/root/etc/e-smith/events/actions/startpage-force
new file mode 100644
index 0000000..9249243
--- /dev/null
+++ b/root/etc/e-smith/events/actions/startpage-force
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+
+import subprocess
+import json
+import sys
+import os
+import fnmatch
+
+def set_startpage_firefox(homedir):
+ d = homedir + '/.mozilla/firefox/'
+ profiles = []
+ for root, dirs, files in os.walk(d):
+ for name in dirs:
+ p = os.path.join(root, name + '/prefs.js')
+ if os.path.isfile(p):
+ profiles.append(p)
+ for p in profiles:
+ with open(p, 'a') as f:
+ txt='user_pref("browser.startup.homepage", "http://' + _fqdn + '");'
+ f.write(txt)
+ return
+
+def set_startpage_chrome(homedir):
+ d = homedir + '/.config/google-chrome/'
+ profiles = []
+ for root, dirs, files in os.walk(d):
+ for name in dirs:
+ p = os.path.join(root, name + '/Preferences')
+ if os.path.isfile(p):
+ profiles.append(p)
+ for p in profiles:
+ with open(p) as json_data:
+ data = json.load(json_data)
+ data['homepage'] = 'http://' + _fqdn
+ data['homepage_is_newtabpage'] = False
+ data['browser']['show_home_button'] = True
+ data['session']['restore_on_startup'] = 4
+ data['session']['startup_urls'] = ['http://' + _fqdn]
+ with open(p, 'w') as f:
+ json.dump(data, f)
+ return
+
+def set_startpage_chromium(homedir):
+ d = homedir + '/.config/chromium/'
+ profiles = []
+ for root, dirs, files in os.walk(d):
+ for name in dirs:
+ p = os.path.join(root, name + '/Preferences')
+ if os.path.isfile(p):
+ profiles.append(p)
+ for p in profiles:
+ with open(p) as json_data:
+ data = json.load(json_data)
+ data['homepage'] = 'http://' + _fqdn
+ data['homepage_is_newtabpage'] = False
+ data['browser']['show_home_button'] = True
+ data['session']['restore_on_startup'] = 4
+ data['session']['startup_urls'] = ['http://' + _fqdn]
+ with open(p, 'w') as f:
+ json.dump(data, f)
+ return
+
+
+_cfg = json.loads(subprocess.Popen(['/sbin/e-smith/db', 'configuration', 'showjson'],stdout=subprocess.PIPE).communicate()[0])
+_SystemName = [x['type'] for x in _cfg if x['name']=='SystemName'][0]
+_DomainName = [x['type'] for x in _cfg if x['name']=='DomainName'][0]
+_fqdn = _SystemName + '.' + _DomainName
+_users = json.loads(subprocess.Popen(['/sbin/e-smith/db', 'accounts', 'showjson'],stdout=subprocess.PIPE).communicate()[0])
+_users = [x for x in _users if x['type']=='user' and x['name']!='admin']
+
+# if a specific user has been requested, we filter the list
+if len(sys.argv) > 1:
+ _users = [x for x in _users if x['name']==sys.argv[1]]
+
+# if we have some user to parse
+if len(_users) > 0:
+ for u in _users:
+ homedir = '/var/lib/nethserver/home/' + u['name']
+ set_startpage_firefox(homedir)
+ set_startpage_chrome(homedir)
+ set_startpage_chromium(homedir)
+
diff --git a/root/etc/e-smith/events/actions/startpage-refresh b/root/etc/e-smith/events/actions/startpage-refresh
new file mode 100644
index 0000000..010f679
--- /dev/null
+++ b/root/etc/e-smith/events/actions/startpage-refresh
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+import subprocess
+from jinja2 import Template
+import json
+import os
+
+templatedir = '/usr/share/startpage/templates/'
+
+_data = json.loads(subprocess.Popen(['/sbin/e-smith/db', 'startpage', 'showjson'],stdout=subprocess.PIPE).communicate()[0])
+_config = [x for x in _data if x['type']=='configuration'][0]
+_status = _config['props']['status'] == 'enabled'
+_outfile = _config['props']['outfile']
+_template = _config['props']['template']
+
+try:
+ os.remove(_outfile)
+except OSError:
+ pass
+
+if _status:
+ _links = [x for x in _data if x['type']=='link']
+ _links = [x for x in _links if x['props']['enable']=='yes']
+
+ tplfile = templatedir + _template + '.jinja2'
+ with open(tplfile) as file_:
+ template = Template(file_.read())
+ out = template.render(links=_links)
+ with open(_outfile, "wb") as f:
+ f.write(out)
diff --git a/root/etc/e-smith/templates/etc/httpd/conf.d/startpage.conf/50assets b/root/etc/e-smith/templates/etc/httpd/conf.d/startpage.conf/50assets
new file mode 100644
index 0000000..dd0465a
--- /dev/null
+++ b/root/etc/e-smith/templates/etc/httpd/conf.d/startpage.conf/50assets
@@ -0,0 +1,26 @@
+{
+ use strict;
+ use warnings;
+
+ open(my $fh, '-|', 'httpd -v') or die $!;
+ while (my $line = <$fh>) {
+ if ($line =~ /.*Apache\/2\.2.*/) {
+ $OUT .= "
+Alias /startpage /usr/share/startpage/assets
+
+
LibreSchool project - Start page
+