Commit b74eb518 authored by Jondy Zhao's avatar Jondy Zhao

Add +x rights to the customized scripts

Change startup item name from SlapOS-Node to slapos-configure
Check Administrator right before run configure scripts
Add alias of software to client configure file
Run re6stnet as cygwin service on demand
parent f27041e1
This diff is collapsed.
......@@ -102,6 +102,9 @@ done
# Backup slap-runner.html
cp /etc/slapos/scripts/slap-runner.html{,.orig}
# Add right to scripts
chmod +x /usr/local/bin/*
echo Run post-install script successfully.
read -n 1 -t 60 -p "Press any key to exit..."
exit 0
......
......@@ -35,7 +35,7 @@ done
# Remove slapos-configure from windows startup item
#
slapos_run_key='\HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
slapos_run_entry=SlapOS-Node
slapos_run_entry=slapos-configure
echo Removing startup item "$slapos_run_key\\$slapos_run_entry"
regtool -q unset "$slapos_run_key\\$slapos_run_entry"
......
This diff is collapsed.
#! /bin/bash
export PATH=/usr/local/bin:/usr/bin:$PATH
# ======================================================================
# Routine: get_system_and_admins_gids
# Get the ADMINs ids from /etc/group and /etc/passwd
# ======================================================================
get_system_and_admins_ids() {
ret=0
for fname in /etc/passwd /etc/group; do
if ls -ld "${fname}" | grep -Eq '^-r..r..r..'; then
true
else
echo "The file $fname is not readable by all."
echo "Please run 'chmod +r $fname'."
echo
ret=1
fi
done
[ ! -r /etc/passwd -o ! -r /etc/group ] && return 1;
ADMINSGID=$(sed -ne '/^[^:]*:S-1-5-32-544:.*:/{s/[^:]*:[^:]*:\([0-9]*\):.*$/\1/p;q}' /etc/group)
SYSTEMGID=$(sed -ne '/^[^:]*:S-1-5-18:.*:/{s/[^:]*:[^:]*:\([0-9]*\):.*$/\1/p;q}' /etc/group)
if [ -z "$ADMINSGID" -o -z "$SYSTEMGID" ]; then
echo "It appears that you do not have correct entries for the"
echo "ADMINISTRATORS and/or SYSTEM sids in /etc/group."
echo
echo "Use the 'mkgroup' utility to generate them"
echo " mkgroup -l > /etc/group"
warning_for_etc_file group
ret=1;
fi
ADMINSUID=$(sed -ne '/^[^:]*:[^:]*:[0-9]*:[0-9]*:[^:]*,S-1-5-32-544:.*:/{s/[^:]*:[^:]*:\([0-9]*\):.*$/\1/p;q}' /etc/passwd)
SYSTEMUID=$(sed -ne '/^[^:]*:[^:]*:[0-9]*:[0-9]*:[^:]*,S-1-5-18:.*:/{s/[^:]*:[^:]*:\([0-9]*\):.*$/\1/p;q}' /etc/passwd)
if [ -z "$ADMINSUID" -o -z "$SYSTEMUID" ]; then
echo "It appears that you do not have correct entries for the"
echo "ADMINISTRATORS and/or SYSTEM sids in /etc/passwd."
echo
echo "Use the 'mkpasswd' utility to generate it"
echo " mkpasswd -l > /etc/passwd."
warning_for_etc_file passwd
ret=1;
fi
return "${ret}"
} # === get_system_and_admins_ids() === #
#
# Check ipv6 connection by default ipv6 route
#
......@@ -45,6 +90,12 @@ function show_error_exit()
exit 1
}
#-------------------------------------------------
# Check adminsitrator rights
#-------------------------------------------------
get_system_and_admins_ids || show_error_exit "Failed to get uids of system and amdinistrator account."
id | grep -q "$ADMINSUID(Administrators)" || show_error_exit "Error: Administrator right required to run this script."
#-------------------------------------------------
# Constants
#-------------------------------------------------
......@@ -66,25 +117,30 @@ if (( $? )) ; then
echo "No native IPv6."
echo Check re6stnet network ...
which re6stnet > /dev/null 2>&1 || show_error_exit "Error: no re6stnet installed, please run Configure SlapOS first."
service_name=slapos-re6stnet
# re6st-conf --registry http://re6stnet.nexedi.com/ --is-needed
# Check if babeld is running, so we guess whether re6stnet is running or not
ps -ef | grep -q /usr/local/bin/babeld
cygrunsrv --query $service_name >/dev/null 2>&1
if (( $? )) ; then
echo "Start re6stnet ..."
# It need root rights to install tap-driver
cd /etc/re6stnet
[[ -d /var/log/re6stnet ]] || mkdir -p /var/log/re6stnet
re6stnet @re6stnet.conf --ovpnlog -I $slapos_ifname -i $slapos_ifname >> /var/log/re6stnet/slapos-node.log 2>&1 &
disown -h
echo $! > /var/run/slapos-node-re6stnet.pid
echo "Start re6stent (pid=$!) in the background OK."
echo "You can check log files in the /var/log/re6stnet/."
echo
echo "Install slapos-re6stnet service ..."
cygrunsrv -I $service_name -c /etc/re6stnet -p $(which re6stnet) -a "@re6stnet.conf" -u Administrator|| \
show_error_exit "Failed to install $service_name service."
echo "Cygwin $service_name service installed."
# echo "Waiting re6stent network work ..."
# while true ; do
# check_ipv6_connection && break
# done
fi
service_state=$(cygrunsrv --query $service_name | sed -n -e 's/^Current State[ :]*//p')
if [[ ! x$service_state == "xRunning" ]] ; then
echo "Starting $service_name service ..."
cygrunsrv --start $service_name || show_error_exit "Failed to start $service_name service."
service_state=$(cygrunsrv --query $service_name | sed -n -e 's/^Current State[ :]*//p')
fi
[[ x$service_state == "xRunning" ]] || show_error_exit "Failed to start $service_name service."
echo Cygwin $service_name service is running.
echo "You can check log files in the /var/log/re6stnet/*.log"
echo
echo "re6stnet network OK."
else
echo "Native IPv6 Found."
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment