mirror of
https://github.com/YunoHost/install_script.git
synced 2024-09-03 20:06:25 +02:00
More cosmetic / reorganizing / misc cleaning
This commit is contained in:
parent
a3ed5637fc
commit
6cbe6f5399
1 changed files with 80 additions and 76 deletions
156
install_yunohost
156
install_yunohost
|
@ -166,26 +166,21 @@ function step() {
|
||||||
return $return_code
|
return $return_code
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensure_root() {
|
function apt_get_wrapper() {
|
||||||
if [[ "$(id -u)" != "0" ]] ;
|
if [[ "$AUTOMODE" == "0" ]] ;
|
||||||
then
|
then
|
||||||
return 1
|
debconf-apt-progress \
|
||||||
|
--logfile $YUNOHOST_LOG \
|
||||||
|
-- \
|
||||||
|
apt-get $*
|
||||||
|
else
|
||||||
|
apt-get $* >> $YUNOHOST_LOG 2>&1
|
||||||
fi
|
fi
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_pi_logged_out() {
|
|
||||||
who | grep pi > /dev/null && return 1
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_raspbian() {
|
function apt_update() {
|
||||||
# On Raspbian image lsb_release is available
|
apt_get_wrapper update
|
||||||
if [[ "$(lsb_release -i -s 2> /dev/null)" != "Raspbian" ]] ;
|
|
||||||
then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -217,18 +212,6 @@ function check_assertions()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function apt_get_wrapper() {
|
|
||||||
if [[ "$AUTOMODE" == "0" ]] ;
|
|
||||||
then
|
|
||||||
debconf-apt-progress \
|
|
||||||
--logfile $YUNOHOST_LOG \
|
|
||||||
-- \
|
|
||||||
apt-get $*
|
|
||||||
else
|
|
||||||
apt-get $* >> $YUNOHOST_LOG 2>&1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function upgrade_system() {
|
function upgrade_system() {
|
||||||
|
|
||||||
apt_get_wrapper update \
|
apt_get_wrapper update \
|
||||||
|
@ -312,10 +295,6 @@ function setup_package_source() {
|
||||||
wget -O- https://vinaigrette.yunohost.org/yunohost.asc -q | apt-key add -qq - >/dev/null 2>&1
|
wget -O- https://vinaigrette.yunohost.org/yunohost.asc -q | apt-key add -qq - >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
function apt_update() {
|
|
||||||
apt_get_wrapper update
|
|
||||||
}
|
|
||||||
|
|
||||||
function register_debconf() {
|
function register_debconf() {
|
||||||
debconf-set-selections << EOF
|
debconf-set-selections << EOF
|
||||||
slapd slapd/password1 password yunohost
|
slapd slapd/password1 password yunohost
|
||||||
|
@ -407,51 +386,6 @@ function restart_services() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function del_user_pi() {
|
|
||||||
deluser --remove-all-files pi >> $YUNOHOST_LOG 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
function setup_firstboot() {
|
|
||||||
|
|
||||||
cat > /etc/init.d/yunohost-firstboot << EOF
|
|
||||||
#!/bin/sh
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: expand rootfs and Generates new ssh host keys on first boot
|
|
||||||
# Required-Start: \$remote_fs \$syslog
|
|
||||||
# Required-Stop: \$remote_fs \$syslog
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop:
|
|
||||||
# Short-Description: Generates new ssh host keys on first boot
|
|
||||||
# Description: Generates apt-get --purge clean new ssh host keys on $
|
|
||||||
### END INIT INFO
|
|
||||||
echo "Expanding rootfs ..."
|
|
||||||
raspi-config --expand-rootfs
|
|
||||||
echo "Removing myself ..."
|
|
||||||
insserv -r /etc/init.d/yunohost-firstboot
|
|
||||||
rm -f /etc/init.d/yunohost-firstboot
|
|
||||||
rm /etc/yunohost/firstboot
|
|
||||||
echo "Rebooting ..."
|
|
||||||
reboot
|
|
||||||
EOF
|
|
||||||
chmod a+x /etc/init.d/yunohost-firstboot
|
|
||||||
insserv /etc/init.d/yunohost-firstboot
|
|
||||||
touch /etc/yunohost/firstboot
|
|
||||||
}
|
|
||||||
|
|
||||||
function clean_image() {
|
|
||||||
# Delete SSH keys
|
|
||||||
rm -f /etc/ssh/ssh_host_* >> $YUNOHOST_LOG 2>&1
|
|
||||||
yes | ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa >> $YUNOHOST_LOG 2>&1
|
|
||||||
yes | ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa >> $YUNOHOST_LOG 2>&1
|
|
||||||
yes | ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t ecdsa -b 521 >> $YUNOHOST_LOG 2>&1
|
|
||||||
|
|
||||||
# Deleting logs ...
|
|
||||||
find /var/log -type f -exec rm {} \; >> $YUNOHOST_LOG 2>&1
|
|
||||||
|
|
||||||
# Purging apt ...
|
|
||||||
apt-get --purge clean >> $YUNOHOST_LOG 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
function post_install() {
|
function post_install() {
|
||||||
# No postinstall in auto mode
|
# No postinstall in auto mode
|
||||||
[[ "$AUTOMODE" == "1" ]] && return 0
|
[[ "$AUTOMODE" == "1" ]] && return 0
|
||||||
|
@ -499,4 +433,74 @@ Do you want to try again now?
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Raspbian specific stuff #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
function is_raspbian() {
|
||||||
|
# On Raspbian image lsb_release is available
|
||||||
|
if [[ "$(lsb_release -i -s 2> /dev/null)" != "Raspbian" ]] ;
|
||||||
|
then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function user_pi_logged_out() {
|
||||||
|
who | grep pi > /dev/null && return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function del_user_pi() {
|
||||||
|
deluser --remove-all-files pi >> $YUNOHOST_LOG 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_firstboot() {
|
||||||
|
|
||||||
|
cat > /etc/init.d/yunohost-firstboot << EOF
|
||||||
|
#!/bin/sh
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: expand rootfs and Generates new ssh host keys on first boot
|
||||||
|
# Required-Start: \$remote_fs \$syslog
|
||||||
|
# Required-Stop: \$remote_fs \$syslog
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop:
|
||||||
|
# Short-Description: Generates new ssh host keys on first boot
|
||||||
|
# Description: Generates apt-get --purge clean new ssh host keys on $
|
||||||
|
### END INIT INFO
|
||||||
|
echo "Expanding rootfs ..."
|
||||||
|
raspi-config --expand-rootfs
|
||||||
|
echo "Removing myself ..."
|
||||||
|
insserv -r /etc/init.d/yunohost-firstboot
|
||||||
|
rm -f /etc/init.d/yunohost-firstboot
|
||||||
|
rm /etc/yunohost/firstboot
|
||||||
|
echo "Rebooting ..."
|
||||||
|
reboot
|
||||||
|
EOF
|
||||||
|
chmod a+x /etc/init.d/yunohost-firstboot
|
||||||
|
insserv /etc/init.d/yunohost-firstboot
|
||||||
|
touch /etc/yunohost/firstboot
|
||||||
|
}
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Image building specific stuff #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
function clean_image() {
|
||||||
|
# Delete SSH keys
|
||||||
|
rm -f /etc/ssh/ssh_host_* >> $YUNOHOST_LOG 2>&1
|
||||||
|
yes | ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa >> $YUNOHOST_LOG 2>&1
|
||||||
|
yes | ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa >> $YUNOHOST_LOG 2>&1
|
||||||
|
yes | ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t ecdsa -b 521 >> $YUNOHOST_LOG 2>&1
|
||||||
|
|
||||||
|
# Deleting logs ...
|
||||||
|
find /var/log -type f -exec rm {} \; >> $YUNOHOST_LOG 2>&1
|
||||||
|
|
||||||
|
# Purging apt ...
|
||||||
|
apt-get --purge clean >> $YUNOHOST_LOG 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
main
|
main
|
||||||
|
|
Loading…
Add table
Reference in a new issue