Skip to content

Instantly share code, notes, and snippets.

@miccolis
Last active July 14, 2016 00:44
Show Gist options
  • Save miccolis/4556878 to your computer and use it in GitHub Desktop.
Save miccolis/4556878 to your computer and use it in GitHub Desktop.
Extracted from the sumologic collector rpm
#!/bin/sh
if id -u sumo >/dev/null 2>&1; then
echo "User sumo exists..."
else
groupadd -f sumo &&
useradd -g sumo sumo
echo "Create user sumo..."
fi
/opt/SumoCollector/collector stop > /dev/null 2>&1 || true
if [ -d /opt/SumoCollector/config ]; then
mv /opt/SumoCollector/config /tmp/sumo_collector_config
fi
if [ -d /opt/SumoCollector/data ]; then
mv /opt/SumoCollector/data /tmp/sumo_collector_data
fi^@#!/bin/sh
echo "configuring collector...."
cd /opt/SumoCollector
mv tanuki/linux64/wrapper . &&
mv tanuki/linux64/libwrapper.so ./19.25-7/bin/native/lib
sed -i 's:${JAVA_COMMAND_LOCATION}:/opt/SumoCollector/jre/bin/java:' config/wrapper.conf &&
sed -i 's:#RUN_AS_USER=:RUN_AS_USER=sumo:' collector
newVer=`cat config/wrapper.conf |grep wrapper.java.classpath.1 | cut -d/ -f2`
changed=false
if [ -d /tmp/sumo_collector_config ]; then
rm -rf config
mv /tmp/sumo_collector_config config
changed=true
fi
if [ -d /tmp/sumo_collector_data ]; then
rm -rf data
mv /tmp/sumo_collector_data data
changed=true
fi
if $changed ;then
oldVer=`cat config/wrapper.conf |grep wrapper.java.classpath.1 | cut -d/ -f2`
sed -i "s/$oldVer/$newVer/" config/wrapper.conf
fi
chmod +x jre/bin/* &&
chmod +x collector &&
rm -rf tanuki &&
rm -rf *.bat &&
rm -rf script &&
chown -R sumo:sumo /opt/SumoCollector &&
./collector install
echo "SumoLogic collector has been successfully installed, please start it via service or init.d script."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment