Cài đặt DSpace tự động trên Ubuntu!

Discussion in 'Huớng dẫn, tài liệu Dspace' started by Phạm Quang Quyền, Jul 18, 2019.

  1. Phạm Quang Quyền

    Phạm Quang Quyền Administrator Staff Member

    Đây là các lệnh cài đặt tự động DSpace
    Nguồn: https://github.com/royopa/dspace-auto-install/blob/master/build-dspace

    #!/bin/bash
    # set DSpace version to install
    VERSION_DSPACE="5.2"
    dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
    if [ "$dist" == "Ubuntu" ]; then
    sudo locale-gen en_US en_US.UTF-8 pt_BR.UTF-8
    sudo dpkg-reconfigure locales
    sudo apt-get install -y --force-yes software-properties-common python-software-properties language-pack-en build-essential
    sudo apt-get install -y --force-yes git wget unzip mc openjdk-7-jdk maven curl ant ant-optional tomcat7 postgresql tomcat7-admin
    else
    sudo yum install -y git wget unzip mc openjdk-7-jdk maven curl ant ant-optional tomcat7 postgresql tomcat7-admin
    fi
    # check if user vagrant exists
    vagrant_user_exists=false
    getent passwd vagrant >/dev/null 2>&1 && vagrant_user_exists=true
    # se estiver no vagrant vai para o diretório do auto install
    if $vagrant_user_exists; then
    cd dspace-auto-install
    fi
    #copiar o arquivo do tomcat
    sudo cp tomcat7 /etc/default/tomcat7
    echo Copying LiveCD ROOT webapp to tomcat
    sudo cp -R ROOT /var/lib/tomcat7/webapps/ROOT
    #copiar o arquivo do postgresql
    sudo cp pg_hba.conf /etc/postgresql/*/main/pg_hba.conf
    # Clean up any old installation
    echo Removing /dspace
    sudo rm -rf /dspace/*
    # Make the relevant directories
    echo - Making /dspace
    sudo useradd -m dspace
    sudo mkdir /dspace
    sudo chown dspace /dspace
    # Stop tomcat
    echo Stopping tomcat
    sudo service tomcmvat7 stop
    # Restart postgresql
    echo Restarting service postgresql
    sudo service postgresql restart
    # Create the postgres user and database
    echo Initalise the database
    echo - Dropping old dspace database
    sudo -u postgres dropdb dspace
    echo - Dropping old dspace Postgres users
    sudo -u postgres dropuser dspace
    echo - Creating the dspace Postgres user
    sudo -u postgres psql "-c CREATE USER dspace WITH PASSWORD 'dspace' CREATEDB;"
    echo - Creating the dspace database
    createdb -U dspace dspace
    # Download DSpace
    echo Download DSpace source
    echo - Removing old copy of /dspace-src
    sudo rm -rf /dspace-src/*
    echo - Downloading new copy of DSpace
    wget "https://github.com/DSpace/DSpace/archive/dspace-$VERSION_DSPACE.zip" -O master.zip
    echo - Extracting the DSpace downloaded
    unzip -o "master.zip"
    # Remove unnecessary file
    echo - Removing file downloaded
    sudo rm "master.zip"
    # Check user dspace
    dspace_user_exists=false
    getent passwd dspace >/dev/null 2>&1 && dspace_user_exists=true
    # Make the relevant directories
    echo - Making /dspace-src
    sudo rm -rf /dspace-src/*
    sudo mkdir /dspace-src
    if $vagrant_user_exists; then
    sudo chown vagrant /dspace-src
    fi
    if $dspace_user_exists; then
    sudo chown dspace /dspace-src
    fi
    echo - "Copying DSpace-master to /dspace-src"
    sudo cp -R "DSpace-dspace-$VERSION_DSPACE/"* /dspace-src
    # Remove unnecessary folder
    rm -rf "DSpace-master"
    # Build DSpace-installed
    echo Building DSpace
    # Change build.properties
    echo - Copying build.properties to /dspace-src/build.properties
    sudo cp -f build.properties /dspace-src/build.properties
    # Copy dspace.cfg
    echo - Copying dspace.cfg to /dspace-src/dspace.cfg
    sudo cp -f dspace.cfg /dspace-src/dspace.cfg
    # Copy ROOT
    echo - Copying ROOT to /dspace-src/ROOT
    sudo cp -R ROOT /dspace-src/ROOT
    # Set MAVEN_OPTS with 1024M memory
    echo - Set MAVEN_OPTS with 1024M memory
    export MAVEN_OPTS=-Xmx1024M
    echo - Running 'mvn package' on /dspace-src
    cd /dspace-src/dspace
    sudo mvn -X package
    echo - Coping the customized dspace.cfg to /{dspace-build}/config
    cd ~ && cd dspace-auto-install-master
    sudo cp dspace.cfg "/dspace-src/dspace/target/dspace-installer/config/dspace.cfg"
    echo - Running ant fresh_install
    cd "/dspace-src/dspace/target/dspace-installer/"
    sudo ant fresh_install
    # Create an admin user
    echo Creating a DSpace admin user: username = dspace password = dspace
    sudo /dspace/bin/dspace create-administrator -e dspace -f DSpace -l User -c en -p dspace
    # Delete old tomcat webapps
    echo Deleting old tomcat webapps
    sudo rm -rf /var/lib/tomcat7/webapps/*
    # Copy webapps to tomcat
    echo Link webapps to tomcat
    sudo ln -s /dspace/webapps/jspui /var/lib/tomcat7/webapps/jspui
    sudo ln -s /dspace/webapps/oai /var/lib/tomcat7/webapps/oai
    sudo ln -s /dspace/webapps/rdf /var/lib/tomcat7/webapps/rdf
    sudo ln -s /dspace/webapps/rest /var/lib/tomcat7/webapps/rest
    sudo ln -s /dspace/webapps/solr /var/lib/tomcat7/webapps/solr
    sudo ln -s /dspace/webapps/sword /var/lib/tomcat7/webapps/sword
    sudo ln -s /dspace/webapps/swordv2 /var/lib/tomcat7/webapps/swordv2
    sudo ln -s /dspace/webapps/xmlui /var/lib/tomcat7/webapps/xmlui
    # Start tomcat
    echo Starting tomcat
    if $vagrant_user_exists; then
    sudo usermod -a -G vagrant tomcat7
    fi
    sudo chown tomcat7:tomcat7 /dspace -R
    sudo service tomcat7 restart
    # All done
    echo Build completed!

    Mình chưa thử cài nhưng với kinh nghiệm hiện có, đọc thì thấy rằng đây là nội dung tập hợp toàn bộ quá trình cài đặt DSpace vào hệ thống Ubuntu.
    Giờ chưa có thời gian test, cũng như máy tính của thư viện không còn nên chưa test, nhưng thấy hay cứ đăng lên đây cho anh/chị/em nào có điều kiện thử.
    CHÚC CÁC BẠN THÀNH CÔNG!
    Tran huu Trung likes this.
     

Share This Page