0

I'm loading and executing this bash file from my preseed file on Ubuntu 18.04.1. The install works perfectly and my bash file is downloaded and executes but with errors.

Error message: "activation/ask does not exist". I tried troubleshooting this and reading the debconf dev configuration but can't really identify what I'm doing wrong. Any ideas? Thanks

EDIT: If i go to shell during installation and wget, chmod this post.sh script, everything works just fine. Any ideas?

#!/bin/sh

# Library to interact with debconf.
. /usr/share/debconf/confmodule

# Create the template file
cat > /tmp/activate.template <<EOL
Template: activation/title
Type: text
Description: Activate

Template: activation/ask
Type: string
Description: Enter Activation Code
EOL

# Load your template
debconf-loadtemplate activation /tmp/activate.template

# Set title for dialogue box
db_settitle activation/title

# Input activation code
db_input critical activation/ask
db_go

# Fetch input from user
db_get activation/ask

# Save it to a file
echo "$RET" > /root/answer.value

#Error message: activation/ask does not exist

The templates are renamed, so don't worry about the mismatch there. Thanks

error

user3323307
  • 243
  • 4
  • 13
  • I manually removed all whitespace and tried to remove all empty lines. And so there would be no doubt, "dos2unix post.sh". Still same problem. I'm using the "ubuntu-18.04.1-server-amd64.iso (749,7 MB)" image, as the latest is using subiquity. But there might be some changes to this image and debconf? – user3323307 Jan 29 '19 at 08:42
  • I have the exact same problem on 16.04.5 – user3323307 Jan 29 '19 at 13:06
  • I was unable to repro in a Docker instance running Xenial, though I got a different, unrelated error message. Is `activate` related to a package which exists locally? – tripleee Jan 29 '19 at 13:27
  • No. Maybe i have misunderstood. I don't have a package at all. Just wanted to take a custom user input and save to file which will be available to use as an activation key for a http post for later. Thanks – user3323307 Jan 29 '19 at 14:43
  • Er, wait ... So you are setting up a fresh Ubuntu instance for each blog post? – tripleee Jan 29 '19 at 15:47
  • Haha. No. May you share the code you used to take user input? I have gotten error code 127 earlier. – user3323307 Jan 30 '19 at 07:48
  • I really don't understand what you are doing here. I have only used preseed to set up new Ubuntu instances but this looks like maybe you are using it for something else entirely. Perhaps [edit] the question to explain what you want to accomplish? – tripleee Jan 30 '19 at 08:07
  • I really just want to ask a user a custom question during install and save the value to a file. Anything besides that is pretty much irrelevant. – user3323307 Jan 30 '19 at 10:49
  • The [manual page](https://www.mankier.com/1/debconf-loadtemplate) says *""**Warning:** This program should never be used from a maintainer script of a package that uses debconf! It may however, be useful in debugging, or to seed the debconf database."* Could that be a clue? – tripleee Jan 30 '19 at 11:08

1 Answers1

0

This had to do with how the script was executed.

d-i preseed/late_command string \
in-target /usr/bin/wget -O /root/post.sh http://<ip>/preseed/post.sh; \
in-target /bin/chmod +x /root/post.sh; \
in-target /bin/bash /root/post.sh
user3323307
  • 243
  • 4
  • 13