NAME
App::CharmKit::Sys
SYNOPSIS
use charm;
or
use App::CharmKit::Sys;
apt_update();
apt_upgrade();
apt_install ['nginx-common', 'redis-server'];
DESCRIPTION
Provides system utilities such as installing packages, managing files, and more.
- spew(STR $path, STR $contents)
-
writes to a file, defaults to utf8
- slurp(STR $path)
-
reads a file, defaults to utf8
- make_dir(STR $dir)
-
mkdir helper for creating directories
- remove_dir(STR $dir)
-
removes directories
- set_owner(STR $user, ARRAYREF $dirs)
-
sets owner of directories
set_owner('ubuntu', ['/var/lib/mydb', '/etc/mydb/conf'])
- getent(STR $db, STR $key)
-
accesses user info from nss
Params
* db: nss database to query * key: what to query * returns: result from
sh
- add_user(STR $user, STR $homedir)
-
adds user to system
Params
* user: username * homedir: users home directory * returns: result from
sh
- del_user(STR $user)
-
removes a user, does attempt to remove home directory
- sh(ARRAYREF $command)
-
Shs a local command:
my $ret = sh(['juju-log', 'a message']); print $ret->{stdout};
Params
* command: command to run * returns: hash of { stdout =>, stderr =>, has_error =>, error => }
- apt_add_repo(STR $repo, STR $key, BOOL $update)
-
Adds a archive repository or ppa. key is required if adding http source.
source can be in the format of:
ppa:charmers/example deb https://stub:key@private.example.com/ubuntu trusty main
- apt_install(ARRAYREF $pkgs)
-
Installs packages via apt-get
apt_install(['nginx']);
- apt_upgrade
-
Upgrades system
apt_upgrade();
- apt_update
-
Update repository sources
apt_update();
- service_control(STR $service_name, STR $action)
-
Controls a upstart service
- service_status(STR $service_name)
-
Get running status of service
- load_helper(STR $name, HASHREF $opts)
-
Helper for bringing in additional utilities. A lot of utilities are exported automatically however, this is useful if more control is required over the helpers.
Params
*
opts
Options to pass into helper class - read_ini(STR $path)
-
Basic config parsing for ini like files like whats found in most of /etc/default. This will also automatically return its root property.
Params
*
path
Path of config file to read
1;