How do I write an installation file? - Parcks/core GitHub Wiki

Consider the following valid installation file:

{
   "name":"Demo installer",
   "install":[
      {
         "package":"parcks",
	 "alternative-names":["php", "dsjgdosfihgsdhg"],
         "post-installation":[
            {
               "type":"remote",
               "name":"composer",
               "url":"https://raw.githubusercontent.com/Parcks/plugins/master/testPlugin.ppl"
            },
            {
               "type":"shell",
	       "name":"demo shell",
               "cmds":[
                  {
                     "root":true,
                     "do":[
                        "whoami",
                        "ls -al"
                     ]
                  },
                  {
                     "root":false,
		     "work-dir":"/opt",
                     "do":[
                        "pwd"
                     ]
                  }
               ]
            },
	    {
		"type":"file-create",
		"name":"test file create as root",
		"destination-path":"/opt/tester",
		"root":true,
		"contents":"Dummy contents\On a new line!"
	    },
	    {
		"type":"file-create",
		"name":"test file create normal",
		"destination-path":"/home/jvalck/test-core",
		"contents":"Dummy contents\On a new line!"
	    },
	    {
		"type":"file-append",
		"name":"test file append normal",
		"destination-path":"/home/jvalck/test-core",
		"contents":"Appended line"
	    },
	    {
		"type":"file-append",
		"name":"test file append as root",
		"destination-path":"/opt/tester",
		"root":true,
		"contents":"Appended line"
	    }
         ]
      }
   ]
}

As you may have noticed, this is a JSON-like file.

Root

At the root level you will need to specify a name for your installer. This is required. The name will be displayed to the user. Next you will specify (as an array) what to install.

Package

Example:

{
         "package":"parcks",
	 "alternative-names":["php", "dsjgdosfihgsdhg"],
         "post-installation":[]
}

Only the package-field is required. To allow that your installer is working on other distro's, it's not a bad idea to add alternative names for the package. You can do this by adding an array containing the alternative names. For example: Debian 8 doesn't has a package called php, it's called php5. Therefore following example allows successful installation of PHP:

{
         "package":"php",
	 "alternative-names":["php5]
}

As stated above, the post-installation-field isn't required either. So you can safely remove it.

Fields

Name Required Type
package Yes string
alternative-names No array
post-installation No array

Post-installation scripts

Remote

Example:

{
    "type":"remote",
    "name":"composer",
    "url":"https://raw.githubusercontent.com/Parcks/plugins/master/testPlugin.ppl"
}

A Remote will download a plugin and execute it. A plugin can contain one or more post-installation scripts. If the url is an unverified one, Parcks will display a warning message. You can find verified plugins in the repository.

Fields

Name Required Type
type Yes string
name Yes string
url Yes string

Shell

Example:

{
  "type":"shell",
  "name":"demo shell",
  "cmds":[
    {
      "root":true,
      "do":[
        "whoami",
        "ls -al"
      ]
    },
    {
      "root":false,
      "work-dir":"/opt",
      "do":[
        "pwd"
      ]
    }
  ]
}

A Shell is a bit more complex (but more powerful) post-installation type, as it contains so-called Shell Commands. The Shell Commands are specified by the cmds-field. We will discuss it below. A Shell is simply a wrapper for one or more Shell Commands.

Fields

Name Required Type
type Yes string
name Yes string
cmds Yes array

Shell Commands

For each Shell Command you must specify if it should be executed with root privileges. In the do-field you specify the commands.

Fields

Name Required Type
root Yes boolean
work-dir No string
do Yes array

File create

Example:

{
  "type":"file-create",
  "name":"test file create as root",
  "destination-path":"/opt/tester",
  "root":true,
  "contents":"Dummy contents\n a new line!"
}

As the name suggest this will create a file in the file system. You can specify the destination of the file with the destination-path-field. The contents are specified in the contents-field.

Warning! As the file is JSON-like, you will need to escape special characters!

If you set the root-field to true, the file will be created as root.

Fields

Name Required Type
type Yes string
name Yes string
destination-path Yes string
contents Yes string
root No boolean

File append

{
  "type":"file-append",
  "name":"test file append normal",
  "destination-path":"/home/jvalck/test-core",
  "contents":"Appended line"
}

The functionality and fields of a File append post-installation script are similar to the File create. The only difference is that it will append to a file instead of creating one.