1 #!/bin/sh 2 # 3 # messagebus-config, Copyright 2009 Yaakov Selkowitz 4 # 5 # This file is part of the Cygwin port of dbus. 6 7 # ====================================================================== 8 # Initialization 9 # ====================================================================== 10 PROGNAME=$(basename $0) 11 _tdir=$(dirname $0) 12 PROGDIR=$(cd $_tdir && pwd) 13 14 CSIH_SCRIPT=/usr/share/csih/cygwin-service-installation-helper.sh 15 16 # Subdirectory where the new package is being installed 17 PREFIX=@prefix@ 18 19 # Directory where the config files are stored 20 SYSCONFDIR=@sysconfdir@/dbus-1 21 DEVDIR=/dev 22 LOGDIR=/var/log 23 RUNDIR=$(dirname @DBUS_SYSTEM_PID_FILE@) 24 SOCKDIR=$(dirname @DBUS_SYSTEM_SOCKET@) 25 26 source ${CSIH_SCRIPT} 27 28 # ====================================================================== 29 # Routine: install_service 30 # Install messagebus as a service 31 # ====================================================================== 32 install_service() { 33 34 if csih_is_nt 35 then 36 37 # Check if messagebus is installed and remove on user request. 38 if cygrunsrv -Q messagebus > /dev/null 2>&1 39 then 40 csih_warning "The messagebus service is already installed." 41 echo 42 if csih_request "Do you want to reinstall it with different args?" 43 then 44 cygrunsrv -E messagebus 45 cygrunsrv -R messagebus 46 fi 47 fi 48 49 # Install messagebus service if it is not already installed 50 if ! cygrunsrv -Q messagebus > /dev/null 2>&1 51 then 52 echo 53 csih_warning "The following function requires administrator privileges!" 54 if csih_request "Do you want to install messagebus as service?" 55 then 56 if cygrunsrv -I messagebus -d "CYGWIN D-Bus system service" -p @EXPANDED_BINDIR@/dbus-daemon -a "--nofork --system" 57 then 58 echo 59 csih_inform "The messagebus service has been installed under the LocalSystem" 60 csih_inform "account (also known as SYSTEM). To start the service now, call" 61 csih_inform "\`net start messagebus' or \`cygrunsrv -S messagebus'. Otherwise, it" 62 csih_inform "will start automatically after the next reboot." 63 echo 64 csih_inform "Check ${SYSCONFDIR}/system.conf first, if it suits your needs." 65 fi 66 fi # user allowed us to install messagebus 67 fi # messagebus already installed 68 fi # csih_is_nt 69 } # --- End of install_service --- # 70 71 72 # ====================================================================== 73 # Main Entry Point 74 # ====================================================================== 75 76 77 # Check how the script has been started. If 78 # (1) it has been started by giving the full path and 79 # that path is /etc/postinstall, OR 80 # (2) Otherwise, if the environment variable 81 # CONFIG_AUTO_ANSWER_NO is set 82 # then set auto_answer to "no". This allows automatic 83 # creation of the config files in /etc w/o overwriting 84 # them if they already exist. In both cases, color 85 # escape sequences are suppressed, so as to prevent 86 # cluttering setup's logfiles. 87 if [ "$PROGDIR" = "/etc/postinstall" ] 88 then 89 csih_auto_answer="no" 90 csih_disable_color 91 fi 92 if [ -n "${CONFIG_AUTO_ANSWER_NO}" ] 93 then 94 csih_auto_answer="no" 95 csih_disable_color 96 fi 97 98 99 # ====================================================================== 100 # Parse options 101 # ====================================================================== 102 while : 103 do 104 case $# in 105 0) 106 break 107 ;; 108 esac 109 110 option=$1 111 shift 112 113 case "$option" in 114 -d | --debug ) 115 set -x 116 csih_trace_on 117 ;; 118 119 -y | --yes ) 120 csih_auto_answer=yes 121 ;; 122 123 -n | --no ) 124 csih_auto_answer=no 125 ;; 126 127 *) 128 echo "usage: ${PROGNAME} [OPTION]..." 129 echo 130 echo "This script creates a basic messagebus configuration." 131 echo 132 echo "Options:" 133 echo " --debug -d Enable shell's debug output." 134 echo " --yes -y Answer all questions with \"yes\" automatically." 135 echo " --no -n Answer all questions with \"no\" automatically." 136 echo 137 exit 1 138 ;; 139 140 esac 141 done 142 143 # ====================================================================== 144 # Action! 145 # ====================================================================== 146 147 # Check for ${SYSCONFDIR} directory 148 csih_make_dir "${SYSCONFDIR}" "Cannot create global configuration files." 149 chmod 775 "${SYSCONFDIR}" 150 setfacl -m u:system:rwx "${SYSCONFDIR}" 151 152 # Check for ${DEVDIR} directory 153 csih_make_dir "${DEVDIR}" "Syslogging using messagebus will not work." 154 chmod 775 "${DEVDIR}" 155 setfacl -m u:system:rwx "${DEVDIR}" 156 157 # Check for ${LOGDIR} directory 158 csih_make_dir "${LOGDIR}" "Syslogging using messagebus will not work." 159 chmod 775 "${LOGDIR}" 160 setfacl -m u:system:rwx "${LOGDIR}" 161 162 # Check for ${RUNDIR} directory 163 csih_make_dir "${RUNDIR}" "PID files of running processes will not be created." 164 chmod 775 "${RUNDIR}" 165 setfacl -m u:system:rwx "${RUNDIR}" 166 167 # Check for ${SOCKDIR} directory 168 csih_make_dir "${SOCKDIR}" "SOCKET files of running processes will not be created." 169 chmod 775 "${SOCKDIR}" 170 setfacl -m u:system:rwx "${SOCKDIR}" 171 172 # maybe: csih_auto_answer=no will skip, 173 # interactive user will get a chance to override 174 install_service 175 176 177 echo 178 echo "Configuration finished. Have fun!" 179