components/ruby/puppet/files/upgrade.sh
changeset 7565 48aa82a0931f
equal deleted inserted replaced
7564:f958607559a6 7565:48aa82a0931f
       
     1 #!/usr/bin/bash -e
       
     2 . /lib/svc/share/smf_include.sh
       
     3 
       
     4 # Get Puppet 4 upgrade flag
       
     5 PUP4_X=$(/usr/bin/svcprop -p upgrade/4.x $SMF_FMRI)
       
     6 
       
     7 # Get list of puppet FMRIs
       
     8 readarray -t PUPPET_FMRI <<< "$(svcs -H -o fmri application/puppet)"
       
     9 
       
    10 # Properties to remove if set
       
    11 PUPPET_RM_PROP=(
       
    12 stringify_facts trusted_node_data allow_variables_with_dashes
       
    13 async_storeconfigs binder catalog_format certdnsnames
       
    14 certificate_expire_warning couchdb_url dbadapter dbconnections
       
    15 dblocation dbmigrate dbname dbpassword dbport dbserver dbsocket
       
    16 dbuser dynamicfacts http_compression httplog ignoreimport
       
    17 immutable_node_data inventory_port inventory_server
       
    18 inventory_terminus legacy_query_parameter_serialization listen
       
    19 localconfig manifestdir masterlog parser preview_outputdir puppetport
       
    20 queue_source queue_type rails_loglevel railslog report_serialization_format
       
    21 reportfrom rrddir rrdinterval sendmail smtphelo smtpport smtpserver
       
    22 stringify_facts tagmap templatedir thin_storeconfigs trusted_node_data zlib
       
    23 disable_warnings classfile vardir libdir rundir confdir ssldir)
       
    24 
       
    25 # If additional migrations are needed in the future use a new prop
       
    26 # and variable for the steps
       
    27 if [ "$PUP4_X" == "true" ] ; then
       
    28   exit $SMF_EXIT_OK
       
    29 fi
       
    30 if [ "$PUP4_X" == "false" ]; then
       
    31   echo "Updating settings for Puppet 4"
       
    32   echo "Removing Out of Date Configuration Options"
       
    33   for fmri in ${PUPPET_FMRI[@]}
       
    34   do
       
    35     for prop in ${PUPPET_RM_PROP[@]}
       
    36     do
       
    37       printf "%s: " ${fmri}/:properties/config/${prop}
       
    38       # Don't exit on error
       
    39       set +e
       
    40       tmp=$(svcprop ${fmri}/:properties/config/${prop} 2> /dev/null)
       
    41       if [ ! -z ${tmp} ]; then
       
    42         svccfg -s $fmri delprop config/${prop} > /dev/null 2>&1
       
    43         # Reset exit on error
       
    44         print "removed (${tmp})"
       
    45       else
       
    46         print "not present"
       
    47       fi
       
    48       set -e
       
    49     done
       
    50   done
       
    51 fi
       
    52 svccfg -s $SMF_FMRI setprop upgrade/4.x = true
       
    53 svccfg -s $SMF_FMRI refresh