about summary refs log tree commit diff stats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/configure.html3
-rw-r--r--core/ports.html3
-rw-r--r--core/scripts/backup-ports.sh130
-rw-r--r--core/scripts/backup-system.sh149
-rw-r--r--core/scripts/restore-ports.sh4
5 files changed, 159 insertions, 130 deletions
diff --git a/core/configure.html b/core/configure.html
index c814091..90c97ea 100644
--- a/core/configure.html
+++ b/core/configure.html
@@ -185,8 +185,7 @@
 	</dl>
 
         <pre>
-        # group -g username username
-        # useradd -u username -g username -m -k /etc/skel -s /bin/bash username
+        # useradd -U -m -k /etc/skel -s /bin/bash username
         # usermod -G adm,wheel,audio,video username
         # passwd username
         </pre>
diff --git a/core/ports.html b/core/ports.html
index 34583d1..e921351 100644
--- a/core/ports.html
+++ b/core/ports.html
@@ -29,8 +29,7 @@
 	Add a user that will be used by ports tools, this example pkgmk;</p>
 
         <pre>
-        # group -r -g pkgmk pkgmk
-        # useradd -r -u pkgmk -g pkgmk -m -d /usr/ports -s /bin/false pkgmk
+        # useradd -r -U -d /usr/ports -s /bin/false pkgmk
         </pre>
 
         <p>You can add your self to group pkgmk. Check if members of this
diff --git a/core/scripts/backup-ports.sh b/core/scripts/backup-ports.sh
index b5667e4..bac18e5 100644
--- a/core/scripts/backup-ports.sh
+++ b/core/scripts/backup-ports.sh
@@ -3,6 +3,9 @@
 DEST_SYS=/usr/ports/releases/stable
 DEST_ARC=/usr/ports/releases/archives
 
+#PACKAGES=/usr/ports/packages
+PACKAGES=/usr/ports/archive/packages
+
 #PRT_GET_FLAGS="-fr -if -is"
 PRT_GET_FLAGS="-fr"
 
@@ -12,90 +15,119 @@ BUILD_NAME="R1D9"
 #echo "${DEST_ARC}/NAME-0.0.0.targ.gz"
 #read BUILD_NAME
 
+#internal
+database=${DEST_SYS}/pkg-db.tar.gz
+ports=${DEST_SYS}/etc-ports.tar.gz
+metadata=${DEST_SYS}/metadata.tar.gz
+build=${DEST_SYS}/metadata/build-version
+portsver=${DEST_SYS}/metadata/ports-releases
+all=${DEST_SYS}/metadata/all-installed
+collinst=${DEST_SYS}/metadata/installed
+notfound=${DEST_SYS}/metadata/not-found
+
 echo "Give build CRUX_RELEASE.VERSION (3.4.X);"
 echo "${DEST_ARC}/${BUILD_NAME}-VERSION.tar.gz"
 read BUILD_VERSION
 
 mkdir -p ${DEST_SYS}
 mkdir -p ${DEST_ARC}
+mkdir -p ${DEST_SYS}/metadata
+
+archive="${DEST_ARC}/${BUILD_NAME}-${BUILD_VERSION}.tar" 
+echo "Creating $archive  ..."
+if [ -f ${archive} ]; then
+	rm ${archive}
+fi
 
 backup_collections() {
 
     # backup collection packages
     while read COLL_VERSION; do
-        COLL_NAME=$(echo $COLL_VERSION | cut -d "-" -f 1)
-        COLL_RELEASE=$(echo $COLL_VERSION | cut -d "-" -f 2)
-
-        while read PORT_NAME; do
-            # get installed version not version on ports
-            PACKAGE=$(grep "^${PORT_NAME}#" ${DEST_SYS}/all-installed.pkg)
-            echo "Backing up package:	${PACKAGE}"
-
-            # check if binary package exist
-            if [ ! -f /usr/ports/packages/${PACKAGE} ]; then
-                echo "Building package: ${PACKAGE};"
-                sudo prt-get update ${PRT_GET_FLAGS} ${PORT_NAME}
-            fi
-
-            if [ -f /usr/ports/packages/${PACKAGE} ]; then
-                echo ${PACKAGE} >> ${DEST_SYS}/${COLL_NAME}-backup.pkg
-                tar rvf ${DEST_SYS}/${COLL_NAME}-${COLL_RELEASE}.tar --directory=/usr/ports/packages ${PACKAGE}
-            else
-                echo "Package ${PACKAGE} from ${PORT_NAME} port not found."
-                echo ${PACKAGE} >> ${DEST_SYS}/${COLL_NAME}-${COLL_RELEASE}-notfound.pkg
-            fi
-        done < ${DEST_SYS}/${COLL_NAME}-installed.pkg
-    done < ${DEST_SYS}/ports_versions.pkg
+	    COLL_NAME=$(echo $COLL_VERSION | cut -d "-" -f 1)
+	    COLL_RELEASE=$(echo $COLL_VERSION | cut -d "-" -f 2)
+
+	    if [ -f ${DEST_SYS}/${COLL_VERSION}.tar ]; then
+	    	rm ${DEST_SYS}/${COLL_VERSION}.tar
+	    fi
+
+	    while read PORT_NAME; do
+		    # get installed version not version on ports
+		    PACKAGE=$(grep "^${PORT_NAME}#" ${all})
+
+		    # check if binary package exist
+		    if [ ! -f /usr/ports/packages/${PACKAGE} ]; then
+			    echo "Building package: ${PACKAGE};"
+			    sudo prt-get update ${PRT_GET_FLAGS} ${PORT_NAME}
+		    fi
+
+		    if [ -f /usr/ports/packages/${PACKAGE} ]; then
+			    echo ${PACKAGE} >> ${DEST_SYS}/metadata/${COLL_NAME}-backup
+			    tar rvf ${DEST_SYS}/${COLL_VERSION}.tar --directory=${PACKAGES} ${PACKAGE}
+		    else
+			    echo "Package ${PACKAGE} from ${PORT_NAME} port not found."
+			    echo ${PACKAGE} >> ${notfound}-${COLL_VERSION}
+		    fi
+    	    done < ${collinst}-${COLL_NAME}
+
+	    tar rvf $archive --directory=${DEST_SYS} ${COLL_VERSION}.tar 
+
+    done < ${portsver}
 }
 
 create_metadata() {
-    echo "${BUILD_NAME}-${BUILD_VERSION}" >> ${DEST_SYS}/build_version
+
+    echo "${BUILD_NAME}-${BUILD_VERSION}" > ${build}
 
     # archive pkgutils data
-    tar --xattrs -zcpf ${DEST_SYS}/pkg-db.tar.gz /var/lib/pkg/db .
+    tar --xattrs -zcpf $database --directory=/var/lib/pkg/ db
+    tar rvf $archive --directory=${DEST_SYS} $(basename ${database})
 
     # archive ports data
-    tar --xattrs -zcpf ${DEST_SYS}/etc_ports.tar.gz --directory=/etc/ports .
+    tar --xattrs -zcpf $ports --directory=/etc/ports .
+    tar rvf $archive --directory=${DEST_SYS} $(basename ${ports})
 
     # must be using gwak instead of sed
-    prt-get listinst -v | sed 's/ /#/g' | sed 's/$/.pkg.tar.gz/g' > ${DEST_SYS}/all-installed.pkg 
+    prt-get listinst -v | sed 's/ /#/g' | sed 's/$/.pkg.tar.gz/g' > ${all}
 
-    if [ -f ${DEST_SYS}/ports_versions ]; then
-        rm ${DEST_SYS}/ports_versions.pkg
+    if [ -f ${portsver} ]; then
+	    rm ${portsver}
     fi
 
     for filename in /etc/ports/*.git; do
-        source $filename
+	source $filename
+
+	echo "${NAME} port collection release (exp; ${BUILD_VERSION}):"
+
+	read RELEASE
+	echo ${NAME}-${RELEASE} >> ${portsver}
 
-        echo "${NAME} port collection release (exp; ${BUILD_VERSION}):"
+	# backup ports collection
+	echo "Backing up collection: 	${NAME}"
+	tar --xattrs -zcpf ${DEST_SYS}/"ports"-${NAME}-${RELEASE}.tar.gz \
+		--directory=/usr/ports/${NAME} \
+		--exclude=.git \
+		.
 
-        read RELEASE
-        echo ${NAME}-${RELEASE} >> ${DEST_SYS}/ports_versions.pkg
+    	tar rvf $archive --directory=${DEST_SYS} "ports"-${NAME}-${RELEASE}.tar.gz
 
-        # backup ports collection
-        echo "Backing up collection: 	${NAME}"
-        tar --xattrs -zcpf ${DEST_SYS}/${NAME}-ports-${RELEASE}.tar.gz \
-            --directory=/usr/ports/${NAME} \
-            --exclude=.git/ \
-            .
+	# create list of installed packages 
+	prt-get printf "%i %p %n\n" | grep "yes /usr/ports/${NAME}" | cut -d " " -f 3 > ${collinst}-${NAME}
 
-        # create list of installed packages 
-        prt-get printf "%i %p %n\n" | grep "yes /usr/ports/${NAME}" | cut -d " " -f 3 > ${DEST_SYS}/${NAME}-installed.pkg
-    done
+done
 }
 
 create_archive() {
-    echo "Creating  ${DEST_ARC}/${BUILD_NAME}-${BUILD_VERSION}.tar.gz ..."
-    tar --xattrs -zcpf ${DEST_ARC}/${BUILD_NAME}-${BUILD_VERSION}.tar.gz --directory=${DEST_SYS} .
+    tar --xattrs -zcpf ${metadata} --directory=${DEST_SYS} metadata/
+    tar rvf $archive --directory=${DEST_SYS} $(basename ${metadata})
 }
 
 update_host() {
-    echo "Creating links to /usr/ports/installed"
-    rm -r /usr/ports/installed
-    pkg_installed
+	echo "Creating links to /usr/ports/installed"
+	rm -r /usr/ports/installed
+	pkg_installed
 
-    echo "Creating ports page"
-    portspage --title=${BUILD_NAME}-${BUILD_VERSION} /usr/ports/installed > /usr/ports/installed/index.html
+	echo "Creating ports page"
+	portspage --title=${BUILD_NAME}-${BUILD_VERSION} /usr/ports/installed > /usr/ports/installed/index.html
 }
 
 create_metadata
diff --git a/core/scripts/backup-system.sh b/core/scripts/backup-system.sh
index 17c8c6a..22fe588 100644
--- a/core/scripts/backup-system.sh
+++ b/core/scripts/backup-system.sh
@@ -3,8 +3,6 @@
 ROOT_DIR=
 DEST_DIR=/root/backup
 DEST_SYS="${DEST_DIR}/system"
-PORT_PKG="${DEST_SYS}/packages"
-PORT_PRT="${DEST_SYS}/ports"
 DATA_CNF="${DEST_DIR}/conf"
 DATA_USR="${DEST_DIR}/user"
 DATA_SRV="${DEST_DIR}/srv"
@@ -31,8 +29,6 @@ print_data () {
     echo "ROOT_DIR=${ROOT_DIR}"
     echo "DEST_DIR=${DEST_DIR}"
     echo "DEST_SYS=${DEST_SYS}"
-    echo "PORT_PKG=${PORT_PKG}"
-    echo "PORT_PRT=${PORT_PRT}"
     echo "DATA_CNF=${DATA_CNF}"
     echo "DATA_USR=${DATA_USR}"
     echo "DATA_SRV=${DATA_SRV}"
@@ -59,8 +55,6 @@ while [ "$1" ]; do
 
             # Destination directory
 	    DEST_SYS="${DEST_DIR}/system"
-	    PORT_PKG="${DEST_SYS}/packages"
-	    PORT_PRT="${DEST_SYS}/ports"
 	    DATA_CNF="${DEST_DIR}/conf"
 	    DATA_USR="${DEST_DIR}/user"
 	    DATA_SRV="${DEST_DIR}/srv"
@@ -80,8 +74,6 @@ done
 print_data
 ConfirmOrExit
 
-mkdir -p ${PORT_PKG}
-mkdir -p ${PORT_PRT}
 mkdir -p ${DATA_CNF}
 mkdir -p ${DATA_USR}
 mkdir -p ${DATA_SRV}
@@ -95,7 +87,79 @@ tar --xattrs -zcpf $DATA_CNF/usr_etc.tar.gz \
     --directory=$ROOT_DIR/usr/etc \
     .
 
+bacup_home_metadata () {
 # User Meta Data
+
+    for dir in /home/*; do
+	if [ "${dir}" != "/home/lost+found" ]; then
+	    user=$(basename $dir)
+	    tar --xattrs -zcpf "${DATA_USR}/meta-${user}.tar.gz" \
+		$dir/.bash_profile \
+		$dir/.bashrc \
+		$dir/.config \
+		$dir/.gitconfig \
+		$dir/.gnupg \
+		$dir/.irssi \
+		$dir/.lynxrc \
+		$dir/.mutt \
+		$dir/.netrc \
+		$dir/.profile \
+		$dir/.spectrwm.conf \
+		$dir/.ssh \
+		$dir/.tmux.conf \
+		$dir/.vim \
+		$dir/.vimrc \
+		$dir/.xinitrc
+
+	    # encript data
+	    #gpg --output "${DATA_USR}/meta-${user}.tar.gz.gpg" \
+		#    --encrypt --recipient user@host \
+		#    "${DATA_USR}/meta-${user}.tar.gz"
+
+	    tar --xattrs -zcpf "${DATA_USR}/gitolite-${user}.tar.gz" \
+		$dir/gitolite-admin
+	fi
+    done
+}
+
+backup_services () {
+    # backup web data first stop php and nginx
+    for pkg_www in ${ROOT_DIR}/srv/www/*; do
+	if [[ ! $(ls ${pkg_www} | grep -v "backup_deploy") = "" ]]; then
+	    pkg_back="${DATA_SRV}/www"
+	    if [ ! -d ${pkg_back} ]; then
+		mkdir -p ${pkg_back}
+	    fi
+	    bck_file="${pkg_back}/$(basename ${pkg_www}).tar.gz"
+	    exc="${pkg_www}/backup_deploy"
+	    tar --exclude ${exc} --xattrs -zcpf ${bck_file} ${pkg_www}
+	fi
+    done
+
+    # backup database data first dump all databases
+    pkg_back="${DATA_SRV}/pgsql"
+    if [ ! -d ${pkg_back} ]; then
+	mkdir -p ${pkg_back}
+    fi
+    pg_dumpall -U postgres | gzip > ${pkg_back}/cluster_dump.gz
+
+    tar --xattrs -zcpf "${pkg_back}/pgsql-conf.tar.gz" \
+	${ROOT_DIR}/srv/pgsql/data/pg_hba.conf \
+	${ROOT_DIR}/srv/pgsql/data/pg_ident.conf \
+	${ROOT_DIR}/srv/pgsql/data/postgresql.conf
+
+
+    # backup gitolite repositories
+    pkg_back="${DATA_SRV}/gitolite"
+    if [ ! -d ${pkg_back} ]; then
+	mkdir -p ${pkg_back}
+    fi
+
+    tar --xattrs -zcpf "${pkg_back}/gitolite.tar.gz" \
+	--directory=${ROOT_DIR}/srv/gitolite \
+	.
+}
+
 while true
 do
     echo "Backup User Metadata ?"
@@ -105,36 +169,7 @@ do
         n|N|no|NO|No) break ;;
         y|Y|YES|yes|Yes)
             echo "Accept - you entered $CONFIRM"
-	    for dir in /home/*; do
-		if [ "${dir}" != "/home/lost+found" ]; then
-		    user=$(basename $dir)
-		    tar --xattrs -zcpf "${DATA_USR}/meta-${user}.tar.gz" \
-			$dir/.bash_profile \
-			$dir/.bashrc \
-			$dir/.config \
-			$dir/.gitconfig \
-			$dir/.gnupg \
-			$dir/.irssi \
-			$dir/.lynxrc \
-			$dir/.mutt \
-			$dir/.netrc \
-			$dir/.profile \
-			$dir/.spectrwm.conf \
-			$dir/.ssh \
-			$dir/.tmux.conf \
-			$dir/.vim \
-			$dir/.vimrc \
-			$dir/.xinitrc
-
-		    # encript data
-		    #gpg --output "${DATA_USR}/meta-${user}.tar.gz.gpg" \
-			#    --encrypt --recipient user@host \
-			#    "${DATA_USR}/meta-${user}.tar.gz"
-
-		    tar --xattrs -zcpf "${DATA_USR}/gitolite-${user}.tar.gz" \
-			$dir/gitolite-admin
-		fi
-	    done
+            bacup_home_metadata
             break
             ;;
         *) echo "Please enter only y or n"
@@ -151,43 +186,7 @@ do
         n|N|no|NO|No) break ;;
         y|Y|YES|yes|Yes)
             echo "Accept - you entered $CONFIRM"
-
-	    # backup web data first stop php and nginx
-	    for pkg_www in ${ROOT_DIR}/srv/www/*; do
-		if [[ ! $(ls ${pkg_www} | grep -v "backup_deploy") = "" ]]; then
-		    pkg_back="${DATA_SRV}/www"
-		    if [ ! -d ${pkg_back} ]; then
-			mkdir -p ${pkg_back}
-		    fi
-		    bck_file="${pkg_back}/$(basename ${pkg_www}).tar.gz"
-		    exc="${pkg_www}/backup_deploy"
-		    tar --exclude ${exc} --xattrs -zcpf ${bck_file} ${pkg_www}
-		fi
-	    done
-
-	    # backup database data first dump all databases
-	    pkg_back="${DATA_SRV}/pgsql"
-	    if [ ! -d ${pkg_back} ]; then
-		mkdir -p ${pkg_back}
-	    fi
-	    pg_dumpall -U postgres | gzip > ${pkg_back}/cluster_dump.gz
-
-	    tar --xattrs -zcpf "${pkg_back}/pgsql-conf.tar.gz" \
-		${ROOT_DIR}/srv/pgsql/data/pg_hba.conf \
-		${ROOT_DIR}/srv/pgsql/data/pg_ident.conf \
-		${ROOT_DIR}/srv/pgsql/data/postgresql.conf
-
-
-	    # backup gitolite repositories
-	    pkg_back="${DATA_SRV}/gitolite"
-	    if [ ! -d ${pkg_back} ]; then
-		mkdir -p ${pkg_back}
-	    fi
-
-	    tar --xattrs -zcpf "${pkg_back}/gitolite.tar.gz" \
-		--directory=${ROOT_DIR}/srv/gitolite \
-		.
-
+            backup_services
             break
             ;;
         *) echo "Please enter only y or n"
diff --git a/core/scripts/restore-ports.sh b/core/scripts/restore-ports.sh
index 39f5178..b53e723 100644
--- a/core/scripts/restore-ports.sh
+++ b/core/scripts/restore-ports.sh
@@ -19,7 +19,7 @@ extract_archives() {
         echo "extracting ${COLL_VERSION}.tar to /usr/ports/packages"
         tar -C /usr/ports/packages -xf ${WORK_DIR}/${COLL_VERSION}.tar
         rm ${WORK_DIR}/${COLL_VERSION}.tar
-    done < ${WORK_DIR}/ports_versions.pkg
+    done < ${WORK_DIR}/metadata/ports-releases
 }
 
 update_system() {
@@ -30,7 +30,7 @@ update_system() {
     while read COLL_VERSION; do
         COLL_NAME=$(echo $COLL_VERSION | cut -d "-" -f 1)
         ports -u $COLL_NAME
-    done < ${WORK_DIR}/ports_versions.pkg
+    done < ${WORK_DIR}/metadata/ports-releases
 
     # first update with prt-get
     prt-get sysup