Use EXEC with API

Discussion in 'Developers' Forum' started by molahs, Oct 7, 2024.

Tags:
  1. molahs

    molahs Member HowtoForge Supporter

    Hi,
    I am writing some automation that uses the API.
    Essentially, it creates a website, ftp user, db user and database. This is all working, and was pretty straightforward to implement.

    What I am trying to do next is take some pre made site and copy the webfolder to the new site (like a template).
    This means I need to run something similar to this command "cp -R /var/www/clients/client1/web5/web /var/www/clients/clientX/webY/", followed by "chown" with the correct permissions.

    I'd like to use the existing structure and functions of the API. What is the recommended way to achieve this using the API?

    Thanks
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    You must create a server-side plugin for this. Is it always the same site that gets copied every time, or are these different sites?
     
    ahrasis likes this.
  3. Strontium

    Strontium New Member

  4. till

    till Super Moderator Staff Member ISPConfig Developer

    This module makes no sense on an ISPConfig system. First, you would not be able to use ISPConfig on that server, and then mod_bhost_alias is not able to run multiple sites securely with separate user permissions. This module is something of the past e.g. to mass host websites with static HTML.
     
    Strontium and ahrasis like this.
  5. molahs

    molahs Member HowtoForge Supporter

    There are multiple sites that can be copied.
    I noticed in the current API there is code which executes shell, but I couldn't figure out how to use it.
    Perhaps I can write an additional function in the API files?

    Thanks
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no such function in the API to run exec commands via API.

    This will not help you as the API runs as unprivileged user, so it will not be able to copy files into websites.

    If you want to implement a new API function, you will have to implement a function in the API to store a value in the database and then also code a server side plugin which then executes the commands to copy the site.
     
  7. molahs

    molahs Member HowtoForge Supporter

    Thanks Till.
     

Share This Page