Koozali.org formerly Contribs.org

Mojolicious

Online ReetP

  • *
  • 2,119
Mojolicious
« on: January 17, 2018, 11:59:30 AM »
I have posted on the devinfo list but thought I'd add something here.

I have been messing with mojolicious. There has been a lot of chat about trying to build a new server manager with it, but that would need an entire framework designed and built and is well beyond me.

So I was curious about it and my aim was to try and produce a simple panel which could integrate with the existing server manager to allow me to easily change my ipsec stuff as it has lots of config items and is tricky on the CLI and easy to make typos for important settings.

I have no idea whether I can successfully do this. However, I can see the potential of Mojo.

I have opened a git repo here if anyone is interested in playing - either make a PR or mail me your username and I can add you as a collaborator:

https://github.com/reetp/mojotests

Essentially create an ibay, make sure it allows executable content, drop the file into the cgi-bin dir and make sure the perms are set as follows:

Code: [Select]
chown root:www *.cgi;chmod 0750 *.cgi;chmod u+s *.cgi
(I am not 100% sure if that is tight enough, but it will at least run!)

Install mojo:

yum install perl-Mojolicious --enablerepo=fws

You can clone the file into the cgi-bin dir like this:

Code: [Select]
git clone https://github.com/reetp/mojotests .
The code has a hard coded link to a css file which you may want to modify.

It has a dropdown that you can select and then submit which returns you back to the original page. I am not sure yet how to capture the selected items..... I'll figure that today I hope :-)

Something that the documentation didn't easily explain here http://mojolicious.org/perldoc/Mojolicious/Plugin/TagHelper was how to get the form to actually react.

I realised you had to wrap the template tags with <form> tags which it doesn't mention !

I had this code form the docs:

Code: [Select]
<%= select_field 'networks' => [ @{ stash('stuff') }], id=> 'dropdown' %>

But it actually needed wrapping like this:

Code: [Select]
<form name="networks" action="./readtest1.cgi/agent" method="POST">
<%= select_field 'networks' => [ @{ stash('stuff') }], id=> 'dropdown' %>
<input type="submit" value="Submit">
</form>

That applies to all the helper tags....

Once I had figured that we were off to the races.

Please have a play and let me know how you get on !

...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline TerryF

  • grumpy old man
  • *
  • 1,113
Re: Mojolicious
« Reply #1 on: January 25, 2018, 11:45:08 PM »
Just a little bit of action beginning, and I do mean a beginning, first steps, BUT, if more of you get involved it has the potential to be a revolution.

Join in - https://lists.contribs.org/pipermail/devinfo/2018-January/date.html
--
qui scribit bis legit

Online ReetP

  • *
  • 2,119
Re: Mojolicious
« Reply #2 on: January 26, 2018, 12:11:06 AM »
The dev posts are long. In short I took the following bootstrap/jquery template that Tony Keane (RIP mate) built as a quick demo:

https://home.reetspetit.net/testbay/server-manager/main.html

(Note nothing works.... it is just a framework)

And recreated the same thing plus a few simple form elements with perl-mojo:

https://home.reetspetit.net/testbay/cgi-bin/template.cgi

(The form bits do return values as proof of concept)

The basics were surprisingly easy. I built it in about 4 days of spare time having known nothing of mojo.

I spelled out my thoughts on the dev list but there is a limit to my coding.

One key point is how to modify some core elements so you get an effective API that ANY app could call with no perl knowledge. For an exprerenced dev it is probably trivial, but I am not that person.

I can probably do a certain amount but it needs greater minds than mine.

Any ideas or assistance appreciated.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Re: Mojolicious
« Reply #3 on: June 13, 2019, 03:23:47 PM »
Hi,

I come back to a somewhat old subject that seems abandoned. I find it hard to accept that this interesting idea is disappearing.
I am resuming work on smeserver-manager2 based on mojolicious and I would like to share it.
I made a local build. I can build it on the buildsys server if that’s desirable.

I have reproduced the current manager behavior using a classic mojolicious application structure (without updates [actions] for now). A structure that must be enriched and improved, of course.

Your reactions are welcome as always.

smeserver-manager-0.1.0-4 available at http://repos.misouk.com/Sme_Server/7/x86_64/smeserver-manager-0.1.0-4.el7.sme.x86_64.rpm

for a  sme10 test server of course  :-)

Please note that :
  • perl-mojolicious-Plugin-I18N is required (from Epel)
  • an expand-template of /etc/httpd/admin-conf/httpd.conf is required too
  • and the classic  signal-event post-upgrade; signal-event --reboot

Online ReetP

  • *
  • 2,119
Re: Mojolicious
« Reply #4 on: June 13, 2019, 03:44:03 PM »
Not abandoned but I do not have enough time, or enough skill to progress it.

Did you not use the AdminLTE bootstrap theme as I originally did?

You can still see it here:

https://home.reetspetit.net/testbay/smeserver-manager/old/main.html

It makes theming MUCH easier and gives it a much more modern look and feel - more 2019 instead of 1999.

I did all the hard work for that a long time ago - well actually Tony Keane did the hard work before he died.

Yes, it probably needs bootstap etc updating, and would need some more work on the layout, but you get the basic idea.

I can send you over the core code for what I did if you want.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline TerryF

  • grumpy old man
  • *
  • 1,113
Re: Mojolicious
« Reply #5 on: June 13, 2019, 04:46:02 PM »
Your reactions are welcome as always.
for a  sme10 test server of course  :-)

I'll play :-)

Please oh please have a chat with John, we need some progress...good job...
--
qui scribit bis legit

Online ReetP

  • *
  • 2,119
Re: Mojolicious
« Reply #6 on: June 13, 2019, 07:38:55 PM »
Note also JPP had already seup a rough "server-manager 2"

Have a look in cvs if you haven't already.

Note also my discussions regarding issues converting over some modules to make a lose 'API' that was easily accessible.

Yes, you can just try and 'recreate' the SM but this was always a chance to bring it into the 21st century as well.

By all means talk to me. Here, dev list, and best on rocket chat.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Re: Mojolicious
« Reply #7 on: June 14, 2019, 09:29:39 PM »
happy to see your quick reactions.

Note also JPP had already setup a rough "server-manager 2"

I started there... but did not find all the patches.

Note also my discussions regarding issues converting over some modules to make a lose 'API' that was easily accessible.

I admit I got a little lost in that long e-mail exchange, a year later.


Did you not use the AdminLTE bootstrap theme as I originally did?

I’m just trying to define an architecture for now and yes I am interested in the work you have produced and that of stefano too.

For sure there are many possibilities and there will no doubt be difficulties of choice.

Offline brianr

  • *
  • 898
Re: Mojolicious
« Reply #8 on: June 16, 2019, 08:44:03 PM »
Hi,

I come back to a somewhat old subject that seems abandoned. I find it hard to accept that this interesting idea is disappearing.
I am resuming work on smeserver-manager2 based on mojolicious and I would like to share it.
I made a local build. I can build it on the buildsys server if that’s desirable.

I have reproduced the current manager behavior using a classic mojolicious application structure (without updates [actions] for now). A structure that must be enriched and improved, of course.

Your reactions are welcome as always.

smeserver-manager-0.1.0-4 available at http://repos.misouk.com/Sme_Server/7/x86_64/smeserver-manager-0.1.0-4.el7.sme.x86_64.rpm

for a  sme10 test server of course  :-)

Please note that :
  • perl-mojolicious-Plugin-I18N is required (from Epel)
  • an expand-template of /etc/httpd/admin-conf/httpd.conf is required too
  • and the classic  signal-event post-upgrade; signal-event --reboot

I am trying to install this, but getting this:

Error: Package: smeserver-manager-0.1.0-4.el7.sme.x86_64 (/smeserver-manager-0.1.0-4.el7.sme.x86_64)
           Requires: perl-Mojolicious-Plugin-I18N >= 1.6.2
           Available: perl-Mojolicious-Plugin-I18N-1.6-2.el7.noarch (epel)
               perl-Mojolicious-Plugin-I18N = 1.6-2.el7
Brian j Read
(retired, for a second time, still got 3 installations though)
.........

Re: Mojolicious
« Reply #9 on: June 16, 2019, 09:17:58 PM »
Install the plugin first :
Code: [Select]
yum install perl-Mojolicious-Plugin-I18N  --enablerepo=epel

Offline brianr

  • *
  • 898
Re: Mojolicious
« Reply #10 on: June 17, 2019, 07:32:33 AM »
Install the plugin first :
Code: [Select]
yum install perl-Mojolicious-Plugin-I18N  --enablerepo=epel

It still fails, note the difference between the dependency name and the name of the module (1.6-2 vs 1.6.2)

Code: [Select]
[root@sme10 ~]# yum install perl-Mojolicious-Plugin-I18N  --enablerepo=epel
Loaded plugins: fastestmirror, post-transaction-actions, priorities, smeserver
Loading mirror speeds from cached hostfile
 * base: mirror.netweaver.uk
 * epel: anorien.csc.warwick.ac.uk
 * smeaddons: mirror.pialasse.com
 * smeextras: mirror.pialasse.com
 * smeos: mirror.pialasse.com
 * smeupdates: mirror.pialasse.com
 * updates: mirror.econdc.com
epel                                                                                    | 5.3 kB  00:00:00     
323 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package perl-Mojolicious-Plugin-I18N.noarch 0:1.6-2.el7 will be installed
--> Processing Dependency: perl(Mojolicious) >= 5 for package: perl-Mojolicious-Plugin-I18N-1.6-2.el7.noarch
--> Processing Dependency: perl(Mojo::Base) for package: perl-Mojolicious-Plugin-I18N-1.6-2.el7.noarch
--> Processing Dependency: perl(Mojo::URL) for package: perl-Mojolicious-Plugin-I18N-1.6-2.el7.noarch
--> Processing Dependency: perl(Mojolicious::Plugin) for package: perl-Mojolicious-Plugin-I18N-1.6-2.el7.noarch
--> Running transaction check
---> Package perl-Mojolicious.noarch 0:7.94-2.el7 will be installed
--> Processing Dependency: perl(JSON::PP) for package: perl-Mojolicious-7.94-2.el7.noarch
--> Running transaction check
---> Package perl-JSON-PP.noarch 0:2.27202-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                                  Arch               Version                    Repository        Size
===============================================================================================================
Installing:
 perl-Mojolicious-Plugin-I18N             noarch             1.6-2.el7                  epel              13 k
Installing for dependencies:
 perl-JSON-PP                             noarch             2.27202-2.el7              base              55 k
 perl-Mojolicious                         noarch             7.94-2.el7                 epel             1.0 M

Transaction Summary
===============================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 1.1 M
Installed size: 2.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): perl-JSON-PP-2.27202-2.el7.noarch.rpm                                            |  55 kB  00:00:00     
(2/3): perl-Mojolicious-Plugin-I18N-1.6-2.el7.noarch.rpm                                |  13 kB  00:00:00     
(3/3): perl-Mojolicious-7.94-2.el7.noarch.rpm                                           | 1.0 MB  00:00:00     
---------------------------------------------------------------------------------------------------------------
Total                                                                          1.4 MB/s | 1.1 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : perl-JSON-PP-2.27202-2.el7.noarch                                                           1/3
  Installing : perl-Mojolicious-7.94-2.el7.noarch                                                          2/3
  Installing : perl-Mojolicious-Plugin-I18N-1.6-2.el7.noarch                                               3/3
  Verifying  : perl-JSON-PP-2.27202-2.el7.noarch                                                           1/3
  Verifying  : perl-Mojolicious-Plugin-I18N-1.6-2.el7.noarch                                               2/3
  Verifying  : perl-Mojolicious-7.94-2.el7.noarch                                                          3/3

Installed:
  perl-Mojolicious-Plugin-I18N.noarch 0:1.6-2.el7                                                             

Dependency Installed:
  perl-JSON-PP.noarch 0:2.27202-2.el7                   perl-Mojolicious.noarch 0:7.94-2.el7                 

Complete!
[root@sme10 ~]# yum localinstall ./smeserver-manager-0.1.0-4.el7.sme.x86_64.rpm
Loaded plugins: fastestmirror, post-transaction-actions, priorities, smeserver
Examining ./smeserver-manager-0.1.0-4.el7.sme.x86_64.rpm: smeserver-manager-0.1.0-4.el7.sme.x86_64
Marking ./smeserver-manager-0.1.0-4.el7.sme.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package smeserver-manager.x86_64 0:0.1.0-4.el7.sme will be installed
--> Processing Dependency: perl-Mojolicious-Plugin-I18N >= 1.6.2 for package: smeserver-manager-0.1.0-4.el7.sme.x86_64
Loading mirror speeds from cached hostfile
 * base: mirror.freethought-internet.co.uk
 * smeaddons: mirror.pialasse.com
 * smeextras: mirror.pialasse.com
 * smeos: mirror.pialasse.com
 * smeupdates: mirror.pialasse.com
 * updates: mirror.econdc.com
--> Finished Dependency Resolution
Error: Package: smeserver-manager-0.1.0-4.el7.sme.x86_64 (/smeserver-manager-0.1.0-4.el7.sme.x86_64)
           Requires: perl-Mojolicious-Plugin-I18N >= 1.6.2
           Installed: perl-Mojolicious-Plugin-I18N-1.6-2.el7.noarch (@epel)
               perl-Mojolicious-Plugin-I18N = 1.6-2.el7
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
[root@
Brian j Read
(retired, for a second time, still got 3 installations though)
.........

Re: Mojolicious
« Reply #11 on: June 17, 2019, 08:49:53 AM »
you’re right. I’m looking at it today.

Re: Mojolicious
« Reply #12 on: June 17, 2019, 12:08:22 PM »
new release : http://repos.misouk.com/Sme_Server/7/x86_64/smeserver-manager-0.1.0-5.el7.sme.x86_64.rpm

  • perl-mojolicious-Plugin-I18N is required (from Epel)
  • no more need to manually expand /etc/httpd/admin-conf/httpd.conf
  • signal-event post-upgrade; signal-event --reboot
  • access with "https://your_server/server-manager2"
  • only modules in Miscellaneous  and online-manual have changed

Offline brianr

  • *
  • 898
Re: Mojolicious
« Reply #13 on: June 17, 2019, 01:07:51 PM »
Ok, that installed fine.

However it is not letting me login using the admin/root password.

I'v'e checked the password is correct using the text based server manager from the text config.
Brian j Read
(retired, for a second time, still got 3 installations though)
.........

Re: Mojolicious
« Reply #14 on: June 17, 2019, 04:27:42 PM »
Strange, it is the same login that server-manager.

I have verified on my test server in text and normal mode, manager and manager2 : all is ok !!

I suppose that you are testing with admin username and password....

Do you have some informations in log files ?