daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Nov 15th, 2017 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5.  
  6. [ -f /etc/default/dcache ] && . /etc/default/dcache      
  7. [ -f /etc/dcache.env ] && . /etc/dcache.env              
  8.  
  9. if [ -z "$DCACHE_HOME" ]; then                            
  10. DCACHE_HOME="/usr/share/dcache"                        
  11. fi                                                        
  12. if [ ! -d "$DCACHE_HOME" ]; then                          
  13. echo "$DCACHE_HOME is not a directory"                  
  14. exit 2                                                  
  15. fi                                                        
  16.  
  17. DCACHE_CLASSPATH=${DCACHE_HOME}/classes/*                
  18. DCACHE_DEFAULTS=${DCACHE_HOME}/defaults                  
  19. DCACHE_CACHED_CONFIG=/var/lib/dcache/config/cache        
  20. . ${DCACHE_HOME}/lib/loadConfig.sh                        
  21. if [ "$(id -u)" -eq 0                                       -a -f /lib/systemd/system-generators/dcache-generator  -a "$(basename $0)" != "dcache-generator"              -
  22. a -f /bin/systemctl ]; then                        
  23. for unit in /run/systemd/generator/dcache@*.service; do
  24. if [ "$DCACHE_CACHED_CONFIG" -nt "$unit" ]; then      
  25. systemctl daemon-reload                            
  26. break                                              
  27. fi                                                    
  28. done                                                    
  29. fi
  30.  
  31.  
  32. wantdir="$1/dcache.service.wants"
  33. mkdir "$wantdir"
  34.  
  35. for domain in $(getProperty dcache.domains); do
  36.     RESTART_DELAY="$(getProperty dcache.restart.delay "$domain")"
  37.     USER="$(getProperty dcache.user "$domain")"
  38.     JAVA_OPTIONS="$(getProperty dcache.java.options "$domain")"
  39.     HOME="$(getProperty dcache.home)"
  40.     CLASSPATH="$(printClassPath "$domain")"
  41.     JAVA_LIBRARY_PATH="$(getProperty dcache.java.library.path "$domain")"
  42.  
  43.     cat <<-EOF > "$1/dcache@$domain.service"
  44.     [Unit]
  45.     Description=dCache $domain domain
  46.     After=network.target zookeeper.service
  47.     PartOf=dcache.service
  48.     ReloadPropagatedFrom=dcache.service
  49.     Before=dcache.service
  50.  
  51.     [Service]
  52.     Type=simple
  53.     WorkingDirectory=${HOME}
  54.     Restart=always
  55.     RestartSec=${RESTART_DELAY}
  56.     SuccessExitStatus=143
  57.     ProtectSystem=full
  58.     ProtectHome=true
  59.     NoNewPrivileges=true
  60.     StandardOutput=journal
  61.     SyslogIdentifier=dcache@$domain
  62.     Environment="CLASSPATH=$CLASSPATH" "LD_LIBRARY_PATH=$JAVA_LIBRARY_PATH"
  63.     $( [ -z "$USER" ] || echo "User=$USER" )
  64.     ExecStart=${JAVA} ${JAVA_OPTIONS} "-Ddcache.home=$HOME" "-Ddcache.paths.defaults=${DCACHE_DEFAULTS}" org.dcache.boot.BootLoader start ${domain}
  65.  
  66.     [Install]
  67.     WantedBy=default.target
  68.     EOF
  69.  
  70.     ln -s "$1/dcache@$domain.service" "$wantdir/dcache@$domain.service"
  71. done
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top