✓ Solved

StackScript #1 syntax error (not a valid identifier)

When I tried to use a function apache_virtualhost in my StackScript with source <ssinclude StackScriptID="1">, I got an error:

/root/ssinclude-1: line 542: local: `[': not a valid identifier
/root/ssinclude-1: line 542: local: `==': not a valid identifier
/root/ssinclude-1: line 542: local: `]': not a valid identifier

The line numbered code for stackscript #1 (/root/ssinclude-1) is as follows:

 534   │ function apache_virtualhost {
 535   │     # $1 - required - the hostname of the virtualhost to create
 536   │     [ ! -n "$1" ] && {
 537   │         printf "apache_virtualhost() requires the hostname as the first argument\n"
 538   │         return 1;
 539   │     }
 540   │     local -r vhostname="$1"
 541   │     [ "${detected_distro[family]}" == 'debian' ] && \
 542   │         local -r vhostfile="/etc/apache2/sites-available/$vhostname.conf" \
 543   │     [ "${detected_distro[family]}" == 'redhat' ] && \
 544   │         local -r vhostfile="/etc/httpd/conf.d/vhost.conf"
 545   │ 

Based on the error message, the backslash at the end of line 542 is probably unnecessary.

I would like to fix this and use it without errors. I could not figure out how to contact the person who maintains stackscript.

Thanks in advance,

3 Replies

✓ Best Answer

I could not figure out how to contact the person who maintains stackscript.

I wouldn't even bother… Unless this person is extremely diligent and/or maintaining the script is part of his/her (job) performance evaluation criteria, the errors are probably not going to get fixed.

Find the script's repository (probably on github), fix it yourself and generate a pull request. That's about the best you can do…

-- sw

Another line #551 mkdir -p "/var/www/html/$vhostname/{public_html,logs}" does not seem to be working correctly either.

# ls -la /var/www/html/example.com/
total 12
drwxr-xr-x 3 root root 4096 Dec 31 17:25 .
drwxr-xr-x 4 root root 4096 Dec 31 17:25 ..
drwxr-xr-x 2 root root 4096 Dec 31 17:25 {public_html,logs}

Is the function not used?

Thanks for your comment!

Unfortunately, I couldn't find the stackscript file in the linode organization on github.
https://github.com/orgs/linode/repositories

So, following the advice you gave me, I make new functions and use them by myself.

Thanks again for your helpful suggestions.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct