summaryrefslogtreecommitdiff
path: root/docs/source/docs/quickstart.rst
blob: a0384e6bd093cee1b6b1705825b3044a74d2a3e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Quickstart
==========

Adding lines to ``fstab``::

    >>> from reconfigure.configs import FSTabConfig
    >>> from reconfigure.items.fstab import FilesystemData
    >>> 
    >>> config = FSTabConfig(path='/etc/fstab')
    >>> config.load()
    >>> print config.tree
    {
        "filesystems": [
            {
                "passno": "0", 
                "device": "proc", 
                "mountpoint": "/proc", 
                "freq": "0", 
                "type": "proc", 
                "options": "nodev,noexec,nosuid"
            }, 
            {
                "passno": "1", 
                "device": "UUID=dfccef1e-d46c-45b8-969d-51391898c55e", 
                "mountpoint": "/", 
                "freq": "0", 
                "type": "ext4", 
                "options": "errors=remount-ro"
            }
        ]
    }
    >>> tmpfs = FilesystemData()
    >>> tmpfs.mountpoint = '/srv/cache'
    >>> tmpfs.type = 'tmpfs'
    >>> tmpfs.device = 'none'
    >>> config.tree.filesystems.append(tmpfs)
    >>> config.save()
    >>> quit()
    $ cat /etc/fstab
    proc    /proc   proc    nodev,noexec,nosuid     0       0
    UUID=dfccef1e-d46c-45b8-969d-51391898c55e / ext4 errors=remount-ro 0 1
    none    /srv/cache      tmpfs   none    0       0

Changing Samba settings::

    >>> from reconfigure.configs import SambaConfig
    >>> config = SambaConfig(path='/etc/samba/smb.conf')
    >>> config.load()
    >>> print config.tree.shares
    [
        {
            "comment": "All Printers", 
            "browseable": false, 
            "create_mask": "0700", 
            "name": "printers", 
            "directory_mask": "0755", 
            "read_only": true, 
            "guest_ok": false, 
            "path": "/var/spool/samba"
        }, 
        {
            "comment": "Printer Drivers", 
            "browseable": true, 
            "create_mask": "0744", 
            "name": "print$", 
            "directory_mask": "0755", 
            "read_only": true, 
            "guest_ok": false, 
            "path": "/var/lib/samba/printers"
        }
    ]
    >>> config.tree.shares[0].guest_ok = True
    >>> print config.tree.shares
    [
        {
            "comment": "All Printers", 
            "browseable": false, 
            "create_mask": "0700", 
            "name": "printers", 
            "directory_mask": "0755", 
            "read_only": true, 
            "guest_ok": true, 
            "path": "/var/spool/samba"
        }, 
        {
            "comment": "Printer Drivers", 
            "browseable": true, 
            "create_mask": "0744", 
            "name": "print$", 
            "directory_mask": "0755", 
            "read_only": true, 
            "guest_ok": false, 
            "path": "/var/lib/samba/printers"
        }
    ]
    >>> config.save()