0

chown command issue in kickstart installation

I'm trying to run a chown myuser:myuser at the end of the %post section in my ks.cfg file. Everything before the chown runs successfully.

ks.cfg

#Generated by Kickstart Configurator
#platform=AMD64 or Intel EM64T

#System language
lang en_US
#Language modules to install
langsupport en_US
#System keyboard
keyboard us
#System mouse
mouse
#System timezone
timezone America/Denver
#Root password
rootpw --disabled
#Initial user
user myuser --fullname "" --iscrypted --password ##############################/
#Reboot after installation
reboot
#Use text mode install
text
#Install OS instead of upgrade
install
#Use hard drive installation media
# harddrive --dir=/ks.cfg --partition=4005-3596
cdrom 
#System authorization infomation
auth  --useshadow  --enablemd5
#Network information
network --bootproto=dhcp --device=eth0
#Firewall configuration
firewall --disabled
#Do not configure the X Window System
skipx

%packages
@ ubuntu-server
openssh-server
build-essential

%post --log=/root/ks-post.log
exec < /dev/tty6 > /dev/tty6 2> /dev/tty6
chvt 6
#mount the cd (ISO in my case) to copy files from it
#since this is chrooted environment
mount /dev/cdrom /mnt
# Make directories
echo "***Making Directories***"
mkdir -p /home/myuser/bcfiles
mkdir -p /home/myuser/bin
# Copy bcsetup files
echo "***Copying bcsetup Files***"
cp -r /mnt/postfiles/bcsetup /home/myuser/bin
cp -r /mnt/postfiles/bcsetup-dev /home/myuser/bin
# Copy bcfiles directory
echo "***Copying bcfiles Directory***"
cp -r /mnt/postfiles/bcfiles /home/myuser/
# Copy myuser Profile Configuration Files
echo "***Copying myuser Profile Configuration Files***"
cp -r /mnt/postfiles/.bash_logout /home/myuser/
cp -r /mnt/postfiles/.bashrc /home/myuser/
cp -r /mnt/postfiles/.profile /home/myuser/
# Applying permissions
echo "***Applying Permissions***"
chown myuser /home/myuser/.bashrc

ks.cfg test with --nochroot

%post --nochroot --log=/root/ks-post.log
# Make directories
echo "***Making Directories***"
mkdir -p /target/home/myuser/bcfiles
mkdir -p /target/home/myuser/bin
# Copy bcsetup files
echo "***Copying bcsetup Files***"
cp -r /cdrom/postfiles/bcsetup /target/home/myuser/bin
cp -r /cdrom/postfiles/bcsetup-dev /target/home/myuser/bin
# Copy bcfiles directory
echo "***Copying bcfiles Directory***"
cp -r /cdrom/postfiles/bcfiles /target/home/myuser/
# Copy myuser Profile Configuration Files
echo "***Copying myuser Profile Configuration Files***"
cp -r /cdrom/postfiles/.bash_logout /target/home/myuser/
cp -r /cdrom/postfiles/.bashrc /target/home/myuser/
cp -r /cdrom/postfiles/.profile /target/home/myuser/
# Applying permissions
echo "***Applying Permissions***"
chown myuser:myuser -R /target/home/myuser/


After the install cat /var/log/installer/syslog | grep kickseed shows:

kickseed: chown: unknown user myuser:myuser


Afterthoughts

I've tried several different routes so far. The same thing happens if I exclude --nochroot from %post. I've seen other ks.cfg configurations using chown myuser.myuser which hasn't worked either. Also attempted chown on individual files within /home/myuser/.

Any suggestions would be very much appreciated.

Updates

/etc/passwd and /etc/group both list myuser. Output of groups myuser: myuser : myuser adm cdrom sudo dip plugdev lpadmin sambashare

Thoughts

At this point in time I'm thinking moving the scripts outside of /home/myuser/bin and into /usr/local/bin where I won't need to rely on chown.

1

I've come across this problem recently and as I see it is one of the first results when googling I'll share the solution with you:

You can see your user is listed in /etc/passwd, however, it is being created after the %post section is executed. So at the time the %post script is running your user has not been created yet. Check the logs in /var/log/installer and search for post

0

I initially opted to do Preseed+Kickstart as I believed there was more functionality. However, after using preseed only I was able to accomplish everything without issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.