2

I have a debian package with static files for a web application with root:root owner. After installing this package I need to change owner of all files for tomcat:tomcat, for example. I've read that this could be done by postinst script. However I don't how I can iterate over all files of package.

I think my script should look something like this:

#!/bin/sh    
set -e
USER="tomcat"

-- iterate over files    
    chown ${USER}:${USER} {current_file}
-- end iterate over files

I'll appreciate for any help.

Taras Velykyy
  • 1,781
  • 1
  • 16
  • 30

1 Answers1

1

Use the find command:

find . -exec chown "${USER}:${USER}" {} +

This will change the permissions recursively starting from the working directory.

user000001
  • 32,226
  • 12
  • 81
  • 108
  • Working directory where files will be installed could contain other files which are not related to deb package. I can't change their owners. If there is a way to get a list of files contained package? – Taras Velykyy Jul 21 '14 at 13:57
  • If you only want a single directory you can do `find directory ...`. Otherwise you could specify which files should be touched with the `-name` or the `-regex` options of the find command. – user000001 Jul 21 '14 at 13:59
  • Merging you answer and comment I've completed my task. Thank you. – Taras Velykyy Jul 21 '14 at 15:39