summaryrefslogtreecommitdiff
path: root/create-fhs-dirs
blob: 53fb1120f2185e59ce8c2c79a8c1351e98f8d75e (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
#!/bin/sh
#
# Create FHS directories below a target directory.
#
# Copyright (C) 2011  Codethink Limited
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

set -e

if [ "$#" != 1 ]
then
    echo "Error: must give target root directory as argument." 1>&2
    exit 1
fi

target="$1"

owner=root
group=root
perms=0755

dirs="
bin
boot
dev
etc
home
lib
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
usr/bin
usr/include
usr/lib
usr/local
usr/local/bin
usr/local/lib
usr/local/share
usr/local/sbin
usr/sbin
usr/share
usr/share/doc
usr/share/info
usr/share/man
usr/share/man1
usr/share/man2
usr/share/man3
usr/share/man4
usr/share/man5
usr/share/man6
usr/share/man7
usr/share/man8
usr/share/misc
var
var/cache
var/lib
var/lock
var/log
var/spool
var/tmp
"

for dirname in $dirs
do
    install -d -o "$owner" -g "$group" -m "$perms" "$target/$dirname"
done

# Fix permissions and ownerships for some special cases.
chown "$owner:$group" "$target/."
chmod "$perms" "$target/."
chmod 01777 "$target/tmp"
chmod 01777 "$target/var/tmp"