class Orientdb < Formula
desc "Graph database"
homepage "https://orientdb.com/"
url "https://orientdb.com/download.php?file=orientdb-community-2.2.15.tar.gz"
sha256 "9a553c9d91eb03d954b085c6ecbe05c54526b166c8ca86f1fb27036b2f4dba03"
bottle do
cellar :any_skip_relocation
rebuild 1
sha256 "359342720516992b900b46b28847870513e30223e45f09f8b2507eb5c5889ecb" => :sierra
sha256 "19ffbe060238c64b9077624a2ff95759767592aec181234a4a7d9f05707c0dbd" => :el_capitan
sha256 "19ffbe060238c64b9077624a2ff95759767592aec181234a4a7d9f05707c0dbd" => :yosemite
end
def install
rm_rf Dir["{bin,benchmarks}/*.{bat,exe}"]
chmod 0755, Dir["bin/*"]
libexec.install Dir["*"]
inreplace "#{libexec}/config/orientdb-server-config.xml", "",
<<-EOS.undent
EOS
inreplace "#{libexec}/config/orientdb-server-log.properties", "../log", "#{var}/log/orientdb"
inreplace "#{libexec}/bin/orientdb.sh", "../log", "#{var}/log/orientdb"
inreplace "#{libexec}/bin/server.sh", "ORIENTDB_PID=$ORIENTDB_HOME/bin", "ORIENTDB_PID=#{var}/run/orientdb"
inreplace "#{libexec}/bin/shutdown.sh", "ORIENTDB_PID=$ORIENTDB_HOME/bin", "ORIENTDB_PID=#{var}/run/orientdb"
inreplace "#{libexec}/bin/orientdb.sh", '"YOUR_ORIENTDB_INSTALLATION_PATH"', libexec
inreplace "#{libexec}/bin/orientdb.sh", 'su $ORIENTDB_USER -c "cd \"$ORIENTDB_DIR/bin\";', ""
inreplace "#{libexec}/bin/orientdb.sh", '&"', "&"
bin.install_symlink "#{libexec}/bin/orientdb.sh" => "orientdb"
bin.install_symlink "#{libexec}/bin/console.sh" => "orientdb-console"
bin.install_symlink "#{libexec}/bin/gremlin.sh" => "orientdb-gremlin"
end
def post_install
(var/"db/orientdb").mkpath
(var/"run/orientdb").mkpath
(var/"log/orientdb").mkpath
touch "#{var}/log/orientdb/orientdb.err"
touch "#{var}/log/orientdb/orientdb.log"
ENV["ORIENTDB_ROOT_PASSWORD"] = "orientdb"
system "#{bin}/orientdb", "stop"
sleep 3
system "#{bin}/orientdb", "start"
sleep 3
ensure
system "#{bin}/orientdb", "stop"
end
def caveats; <<-EOS.undent
The OrientDB root password was set to 'orientdb'. To reset it:
https://orientdb.com/docs/2.2/Server-Security.html#restoring-the-servers-user-root
EOS
end
plist_options :manual => "orientdb start"
def plist; <<-EOS.undent
KeepAlive
SuccessfulExit
Label
homebrew.mxcl.orientdb
ProgramArguments
/usr/local/opt/orientdb/libexec/bin/server.sh
RunAtLoad
WorkingDirectory
/usr/local/var
StandardErrorPath
/usr/local/var/log/orientdb/serror.log
StandardOutPath
/usr/local/var/log/orientdb/sout.log
EOS
end
test do
ENV["CONFIG_FILE"] = "#{testpath}/orientdb-server-config.xml"
ENV["ORIENTDB_ROOT_PASSWORD"] = "orientdb"
cp "#{libexec}/config/orientdb-server-config.xml", testpath
inreplace "#{testpath}/orientdb-server-config.xml", "",
" \n "
begin
assert_match /OrientDB console v.2.2.15/, pipe_output("#{bin}/orientdb-console \"exit;\"")
end
end
end