Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7921259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:31:05+00:00 2026-06-03T16:31:05+00:00

I am writing a Bash script to set some environment variables and then start

  • 0

I am writing a Bash script to set some environment variables and then start a web server. What are some good validation checks to add to the script to make sure it is a fail proof as possible:

  1 #!/bin/bash
  2 
  3 # Allow checking that variables don't get set to empty strings.
  4 set -o nounset
  5 
  6 readonly qi_redmine_base="/srv/redmine"
  7 
  8 if test "${qi_redmine_base}" -eq "notset"
  9 then
 10 »···echo
 11 fi
 12 
 13 readonly qi_redmine_etc="/etc/redmine/default"
 14 
 15 if test "${qi_redmine_etc}" -eq "notset"
 16 then
 17 »···echo
 18 fi
 19 
 20 
 21 readonly RAILS_ETC="${qi_redmine_etc}"
 22 export RAILS_ETC
 23 
 24 readonly RAILS_LOG="${qi_redmine_base}/log"
 25 export RAILS_LOG
 26 
 27 readonly RAILS_VAR="${qi_redmine_base}"
 28 export RAILS_VAR
 29 
 30 readonly RAILS_CACHE="${qi_redmine_base}/tmp"
 31 export RAILS_CACHE
 32 
 33 export RAILS_ENV=production
 34 export X_DEBIAN_SITEID=default
 35 
 36 
 37 ruby /usr/share/redmine/script/server webrick -e production
 38 if [$? -ne 0]; then
 39   echo "Server failed to start"
 40 fi

Any help is greatly appreciated!

Greg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:31:07+00:00Added an answer on June 3, 2026 at 4:31 pm
    help test 
    

    shows some possible test opportunities for strings (lenght > 0) and variables not being undefined.

    There is even a construct to define default values:

       ${parameter:-word}
              Use  Default  Values.   If  parameter is unset or null, the expansion of word is
              substituted.  Otherwise, the value of parameter is substituted.
       ${parameter:=word}
              Assign Default Values.  If parameter is unset or null, the expansion of word  is
              assigned  to parameter.  The value of parameter is then substituted.  Positional
              parameters and special parameters may not be assigned to in this way.
       ${parameter:?word}
              Display Error if Null or Unset.  If parameter is null or unset, the expansion of
              word  (or  a  message  to  that effect if word is not present) is written to the
              standard error and the shell, if it is not interactive, exits.   Otherwise,  the
              value of parameter is substituted.
       ${parameter:+word}
              Use  Alternate  Value.   If  parameter is null or unset, nothing is substituted,
              otherwise the expansion of word is substituted.
    

    (citing man bash).

    In general, you would need to solve the halting problem, to finish your task.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing some expect commands in bash. Script: #!/bin/bash set timeout -1 expect
I am writing a bash script to set up a production server. The tasks
I'm writing a bash script and I have errexit set, so that the script
I am writing a bash script that is supposed to do some confirmation and
I'm writing a Bash script that prints some text to the screen: echo Some
I'm writing a bash script to get some podcasts. The problem is that some
I'm writing a shell script where I'm setting some variables, but I'd like to
I'm writing a Bash script that sets up a Drupal development environment for people
I'm writing a Bash script, and I want to checkout a tag and then
I am writing a bash script to copy a file from a remote server,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.